强制浏览器结束当前步骤
需求:
使用Cucumber 1.0.1和Watir 1.9.2,我需要执行javascript代码以便专有门户进行一些导航。
问题:
我能够通过以下方式执行 JS 代码:
def execute_js(js_code)
@browser.goto("javascript:#{js_code};void(0)")
end
execute_js("doNavigate()")
通过这样做,导航按预期完成,但 Watir 不会重新控制浏览器。
我寻找的内容:
我寻找一个解决方案,让 Watir 在“javascript goto”之后重新控制浏览器。
经过测试的替代方案:
@browser.execute_script('alert("toto");')
给我这个:
execScript
OLE error code:80070005 in <Unknown>
Access Denied.
HRESULT error code:0x80020009
An exception occurred. (WIN32OLERuntimeError)
./features/lib/portal.rb:110:in `tln_main_tab'
本地宝石:
- Ascii85(0.9.0)
- 构建器(3.0.0)
- 捆绑器(1.0.15)
- 水豚(1.0.0)
- 子进程(0.1.9)
- commonwatir(1.9.2)
- 黄瓜(1.0.0) 1)
- diff-lcs (1.1.2)
- ffi (1.0.9 x86-mingw32)
- firewatir (1.9.2)
- fuubar-黄瓜(0.0.12)
- 小黄瓜(2.4.5 x86-mingw32)
- 锄头(2.10.0)
- json(1.5.3)
- json_pure(1.5.3)
- mime-types(1.16)
- nokogiri(1.5。 0x86-mingw32)
- pdf阅读器(0.9.0)
- 大虾(0.11.1)
- 机架(1.3.0)
- 机架测试(0.6.0)
- rake(0.9.2)
- rautomation(0.6.2)
- rspec(2.6.0)
- rspec-core(2.6.4)
- rspec-expectations(2.6) .0)
- rspec-mocks (2.6.0)
- ruby-progressbar (0.0.10)
- rubygems-update (1.8.5)
- rubyzip (0.9.4)
- s4t-utils (1.0.4)
- selenium-webdriver (0.2.2)
- 语法 (1.0.0)
- term-ansicolor (1.0.5)
- ttfunk (1.0.1)
- 用户选择 (1.1.6.1)
- viewcumber (0.1.2)
- watir (1.9.2)
- win32-api (1.4.8) x86-mingw32)
- win32 进程 (0.6.5)
- win32console (1.3.0 x86-mingw32) -windows-api (0.4.0)
- windows-pr (1.2.0)
- xml-simple (1.1.0)
- xpath (0.1.4)
Need:
Using Cucumber 1.0.1 and Watir 1.9.2, I need to execute javascript code in order for a proprietary portal to do some navigation.
Issue:
I am able to execute JS code with the following:
def execute_js(js_code)
@browser.goto("javascript:#{js_code};void(0)")
end
execute_js("doNavigate()")
By doing so, the navigation is done as expected but Watir doesn't re-take control of the browser.
What I look for:
I look for a solution for Watir to re-take control of the browser after the 'javascript goto'.
Tested alternative:
@browser.execute_script('alert("toto");')
gives me this:
execScript
OLE error code:80070005 in <Unknown>
Access Denied.
HRESULT error code:0x80020009
An exception occurred. (WIN32OLERuntimeError)
./features/lib/portal.rb:110:in `tln_main_tab'
Local gems:
- Ascii85 (0.9.0)
- builder (3.0.0)
- bundler (1.0.15)
- capybara (1.0.0)
- childprocess (0.1.9)
- commonwatir (1.9.2)
- cucumber (1.0.1)
- diff-lcs (1.1.2)
- ffi (1.0.9 x86-mingw32)
- firewatir (1.9.2)
- fuubar-cucumber (0.0.12)
- gherkin (2.4.5 x86-mingw32)
- hoe (2.10.0)
- json (1.5.3)
- json_pure (1.5.3)
- mime-types (1.16)
- nokogiri (1.5.0 x86-mingw32)
- pdf-reader (0.9.0)
- prawn (0.11.1)
- rack (1.3.0)
- rack-test (0.6.0)
- rake (0.9.2)
- rautomation (0.6.2)
- rspec (2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
- rspec-mocks (2.6.0)
- ruby-progressbar (0.0.10)
- rubygems-update (1.8.5)
- rubyzip (0.9.4)
- s4t-utils (1.0.4)
- selenium-webdriver (0.2.2)
- syntax (1.0.0)
- term-ansicolor (1.0.5)
- ttfunk (1.0.1)
- user-choices (1.1.6.1)
- viewcumber (0.1.2)
- watir (1.9.2)
- win32-api (1.4.8 x86-mingw32)
- win32-process (0.6.5)
- win32console (1.3.0 x86-mingw32)
-windows-api (0.4.0) - windows-pr (1.2.0)
- xml-simple (1.1.0)
- xpath (0.1.4)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了一个解决方法:
它并不理想,但它启用了 javascript 执行,然后更新 URL 哈希,以便 Watir 知道实际操作已完成,以便 Watir 可以走得更远。
I found a workaround:
It's not ideal, but it enables javascript execution, then updates the URL hash so that Watir knows that an actual action was done, so that Watir can go further.
拒绝访问
错误消息通常与页面上的框架相关。查看 Watir wiki 上的 Frames 页面。Access Denied
error message is usually connected to frames on a page. Take a look at Frames page at Watir wiki.