Watir question,

hi,

I ususally attach the IE window with the below code like

b=Watir::IE.attach(:index,0)

Could anyone please suggest me how to attach the chrome browser like I
shown above

You can only attach to IE because of the COM object that it has exposed
by default.

In order to control the other browsers you need to use the associated
plugins.
These are only active when triggered by Webdriver for security reasons
(otherwise you might get keylogging in your browser by a webdriver-savvy
virus).

hi,

Thanks,What do you mean by associated plugins? How do I use that?

Yes I installed the Chrome driver and Firebox driver as well as IE
driver. And I am automating now, So are you telling that I don’t have
any way to connect to the browser?

For Chrome, there is Chrome Driver. For Firefox, it’s FireWatir. What
Watir does with these is tie the different drivers together under a
single API. You are using them when you launch the browser using
“Watir::Browser.new”, but they will not run during normal browser
launch, so there is no “attach” option with these.

But How could I open chrome browser and firebox browser with WATIR?

Watir::Browser.new :firefox
Watir::Browser.new :chrome

That’s right, you have to open the browser with Watir.

Hi Jeol,

Thanks, But how do you write the corresponding attachment code? I could
write the below code for IE browser

b=Watir::IE.attach(:index,0)

What about Chrome and Mozilla?

Joel P. wrote in post #1170863:

they will not run during normal browser
launch, so there is no “attach” option with these.

You can only attach to Internet Explorer. In order to use another
browser you must launch that browser with Watir and maintain the
connection to the driver.

So you say attaching is not possible for Mozilla and Chrome,right? If
so, what could we do in need of any attachments? how could you automate
that?

hi Jeol, what do you mean by maintain the connection to the driver?

hi, I don’t understand this line “In order to use another
browser you must launch that browser with Watir and maintain the
connection to the driver.”

You meant to say I need to open a new browser? I don’t clearly
understand, Can I attach or not? Can you please write a small code to
explain what do you say here?

I’m not sure how else to explain this. Why don’t you experiment with
different browsers and find out for yourself what they are and are not
capable of.

you open irb, use watir to launch the browser, and keep that browser and
console window active.
Then when you want to use watir on that browser window, you use that irb
session.

I don’t know any code to connect the browser, And I am trying to find
the way to connect, you said ‘maintain the connection to the driver’, If
I understood this, that would have been helpful, that’s what I had asked
the question.

hi Jeol,

I have a problem of accessing the following select_list, Can you please
help me out?

I would give you the two select list code below,

Is there any way could I access this select list?

I used this ‘ng-model’ to access this select_list, but it’s not working
and it throws error.

I picked it up easily enough like this:

b.selects(class: ‘ng-valid’).last.flash

Or this:

b.selects.select { |s|
s.attribute_value(‘ng-model’) == ‘agentoptions’
}.first.flash

If that’s as specific as you can be in order to get the right element,
it’s an issue with the design of the page.