0
votes

I'm testing this on ark.com..

the following code works perfectly for firefox with watir-webdriver but gives me an error for google chrome and opera browsers respectively.

heres the code:

require "rubygems"
require "watir-webdriver"

b = Watir::Browser.new :ff
b.goto "http://www.ark.com"

# Signing in
7.times{b.link(:text, "Sign in").flash}
sleep 3
b.link(:text, "Sign in").click
sleep 3
# Popup
b.text_field(:name, "login_email").set "[email protected]"
b.send_keys :tab
b.text_field(:name, "login_password").set "password"
b.button(:value, "Sign in").click
puts b.title

changing the code as follows gives me errors:

b = Watir::Browser.new :chrome 

or

b = Watir::Browser.new :opera

I get the following error message:

You may only interact with visible elements (Selenium::WebDriver::Error::ElementNotVisibleError)

I've tried the following stack overflow suggestion to no avail How do I use Watir::Waiter::wait_until to force Chrome to wait?

Also, my code works perfectly in firefox but not in other browsers, why might this be the case? Any help would be appreciated. Thanks.

2
What element is it saying isn't visible? Also do you get different errors when you try the .when_present etc. methods that you found in the other Stackoverflow question?anonygoose
What line in your code is generating the error?Chuck van der Linden

2 Answers

3
votes

As mentioned in some other posts, you can full screen the browser with the following:

screen_width = b.execute_script("return screen.width;")
screen_height = b.execute_script("return screen.height;")
b.driver.manage.window.resize_to(screen_width,screen_height)
b.driver.manage.window.move_to(0,0)

Then like anonygoose said, the sign in link should be there (assuming your screen isn't too small).

1
votes

Looking at the website in both Chrome and Firefox I'd say there's some sort of bug or unwanted feature going on with it.

If the web browser you're using is too narrow in width the sign-up button disappears completely.

I'd say that's why you're getting strange errors.

Test this by maximizing the Chrome browser as soon as it launches. From my testing this allows the signup button to be found.

I am not sure of a way to maximize either browser by default, but perhaps someone else on here will know or be able to suggest a way to go about it.