Cucumber 瓦蒂尔可以';在IE和PhantomJS中找不到元素

Cucumber 瓦蒂尔可以';在IE和PhantomJS中找不到元素,cucumber,phantomjs,watir-webdriver,Cucumber,Phantomjs,Watir Webdriver,我在不同浏览器中运行脚本时遇到了一个问题:我的脚本在Chrome、Firefox中运行正常,但IE和PhantomJS存在问题。最奇怪的是,几天前我在PhantomJS中成功地完成了相同的脚本,我确信没有人更改gems/浏览器。 下面是我要执行的脚本: class HomePage .... link(:signInLink, :text=>"Sign In") .... def log_in(username="admin", password="admin123")

我在不同浏览器中运行脚本时遇到了一个问题:我的脚本在Chrome、Firefox中运行正常,但IE和PhantomJS存在问题。最奇怪的是,几天前我在PhantomJS中成功地完成了相同的脚本,我确信没有人更改gems/浏览器。 下面是我要执行的脚本:

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
页面的HTML代码:

<div class="user-display">
<span class="user-actions">
    <a rel="nofollow" href="/RedisCache/Users/Account/LogOn?ReturnUrl=%2FRedisCache%2F">
        Sign In
    </a>
</span>
</div>
当我尝试使用irb“手动”复制这样的场景时,我遇到了下一个尝试单击登录链接(PhantomJS)的异常:

当我在IE浏览器中运行脚本时,无论是运行cucumber还是尝试“手动”单击此链接,都会挂起。正如我所看到的,链接就像失去/接收焦点一样闪烁,仅此而已。 我尝试降级PhantomJS版本并重新安装,但没有任何帮助。 有什么建议吗? IE版本是9.0.8112 PhantomJS版本是1.9.7.0
所有gems都有最新版本。

我以前在:文本选择器和IEDriver方面遇到过问题。这对我来说太挑剔了,有时通过,有时失败。我想换一种:

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

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

phantomjs的问题得到了解决:这是我们主页的大小调整问题(因为lnk中phantomjs窗口标志的起始大小不可见)。解决方案:在开始时将phantomjs窗口的大小调整为适当的值。至于第二个问题(IE浏览器),我仍在寻找解决方案。更换选择器并没有解决这个问题。但是谢谢你的建议。WW并不是一个真正的跨浏览器解决方案。您可能应该记住这一点:正如Alister在他的文章中所说,“但是,作为一名顾问,我经常听到经理们说,我们必须在Internet Explorer中运行我们的WebDriver自动测试。”-这也是我的问题:)但经过几次艰难的交谈,我们最终决定在IE中只运行小场景。从技术角度看:我已经更改了element的选择器,并按照Johnson的建议使其工作。所以我接受他的回答。
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'
link(:SignInLink, href: "/RedisCache/Users/Account/LogOn?ReturnUrl=%2FRedisCache%2F")

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