Smooyk
Smooyk

Reputation: 409

Watir can't find element in IE and PhantomJS

I've got a problem with running scripts in different browsers: My scripts work ok in Chrome, Firefox but there is a problem with IE and PhantomJS. Most curious thing is that a few days ago I successfully completed the same scripts in PhantomJS and I'm sure that no one changes gems/browsers. Here is the script that I want to perform:

class HomePage
   ....
   link(:signInLink, :text=>"Sign In")
   ....
def log_in(username="admin", password="admin123")
   self.signInLink_element.when_present(60).click//hangs here
   self.login_element.when_present(60)
   self.username = username
   self.password = password
   self.signIn_element.click
end

The HTML code for the page:

<div class="user-display">
<span class="user-actions">
    <a rel="nofollow" href="/RedisCache/Users/Account/LogOn?ReturnUrl=%2FRedisCache%2F">
        Sign In
    </a>
</span>
</div>

Running my scripts through cucumber I've gor the next exception(PhantomJS):

timed out after 60 seconds, waiting for {:text=>"Sign In", :tag_name=>"a"} to become present(Watir::Wait::TimeoutError)

When I'm trying to reproduce such scenario "by hand" using irb I've got the next exception on attempt to click on Sign In link(PhantomJS):

Selenium::WebDriver::Error::ElementNotVisibleError: Error Message => 'Element is not currently visible and may not be manipulated'
caused by Request => {"headers":{"Accept":"application/json","Connection":"close","Content-Length":"2","Content-Type":"application/x-www-form-urlencoded","Host":"127.0.0.1:8910","User-Agent":"Ruby"},"httpVersion":"1.1","method":"POST","post":"{}","postRaw":"{}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/ed325840-496d-11e4-9570-2d0549eccb44/element/%3Awdc%3A1412169736003/click"} (ReqHand)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/bridge.rb:638:in `raw_execute'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/bridge.rb:616:in `execute'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/bridge.rb:373:in `clickElement'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/common/element.rb:54:in `click'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:132:in `click'

When I'm running scripts in IE browser it is just hangs whether I'm running cucumber or trying to click this link "by hand". As I can see link just blinking like it lost/receive focus and that's all. I've tried to downgrade PhantomJS version and re-install it, but nothing helps. Any suggestions? IE version is 9.0.8112 PhantomJS version is 1.9.7.0 All gems have the latest versions.

Upvotes: 0

Views: 492

Answers (1)

Johnson
Johnson

Reputation: 1490

I've had issues with the :text selector and IEDriver in the past. It's been super finicky for me, sometimes passing and sometimes failing. I'd switch to one of these:

link(:SignInLink, href: "/RedisCache/Users/Account/LogOn?ReturnUrl=%2FRedisCache%2F")

link(:SignInLink, xpath: "//span[@class='user-actions']/a[contains(@href,'Users/Account/LogOn')]")

Upvotes: 1

Related Questions