是否可以使用 watir 在浏览器中导航回来?

发布于 2024-07-14 07:46:06 字数 120 浏览 5 评论 0原文

我正在创建一个自动化测试,该测试应该向后导航几个步骤。 在 Watir 可以这样做吗?

我正在导航到结果列表页面,并且希望只需单击“返回”(Windows 浏览器)即可返回到测试的开始处。 谢谢

I'm creating an automated tests that should navigate back a few steps.
Is it possible to do so in Watir??

I'm navigating to a resultlist page and want to go back to the start of my test just by clicking back (windows browser).
Thnx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

别念他 2024-07-21 07:46:06

如果您有 Watir::IE 对象,那么 #back 是一种可以执行您正在查找的操作的方法:

http://wtr.rubyforge.org/rdoc/classes /Watir/IE.html#M000245

您看到什么错误?

If you have a Watir::IE object, then #back is a method that does what you are looking for:

http://wtr.rubyforge.org/rdoc/classes/Watir/IE.html#M000245

What error are you seeing?

请止步禁区 2024-07-21 07:46:06

这就是我尝试这样做的方式:

@site.ie.wait_until(1200) { |ie| ie.contains_text(/Sort after/) }
  2.times{@site.ie.back
}

This is how i tried to do it:

@site.ie.wait_until(1200) { |ie| ie.contains_text(/Sort after/) }
  2.times{@site.ie.back
}
離人涙 2024-07-21 07:46:06

使用 Watir 的 #back 调用的示例代码(基于 标准维基百科示例):

 require 'watir'
 test_site = 'http://www.google.com/'
 ie = Watir::IE.new
 ie.goto(test_site)
 ie.text_field(:name, "q").set("pickaxe")
 ie.button(:name, "btnG").click

 if ie.text.include?("Programming Ruby")  
   puts "Test Passed. Found the test string: 'Programming Ruby'."
 else
   puts "Test Failed! Could not find: 'Programming Ruby'." 
 end

 ie.back

 if ie.url == test_site
   puts "Test Passed. Returned to search page."
 else
   puts "Test Failed! URL is now #{ie.url}."
 end

 ie.close

Example code that uses Watir's #back call (based on the standard Wikipedia example):

 require 'watir'
 test_site = 'http://www.google.com/'
 ie = Watir::IE.new
 ie.goto(test_site)
 ie.text_field(:name, "q").set("pickaxe")
 ie.button(:name, "btnG").click

 if ie.text.include?("Programming Ruby")  
   puts "Test Passed. Found the test string: 'Programming Ruby'."
 else
   puts "Test Failed! Could not find: 'Programming Ruby'." 
 end

 ie.back

 if ie.url == test_site
   puts "Test Passed. Returned to search page."
 else
   puts "Test Failed! URL is now #{ie.url}."
 end

 ie.close
软的没边 2024-07-21 07:46:06

您当然可以使用 Watir 执行 JavaScript

@browser.execute_script('window.history.back();')

You certainly can execute JavaScript using Watir.

@browser.execute_script('window.history.back();')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文