在我的页面代码中,有以下脚本标记:
<script>
var oid = "182384";
document.getElementById('container').innerHTML = oGrid;
oGrid.setShowSid(false);
oGrid.calcSize();
setupAllTabs();
var toolbar = setupMenuButtons("btnbar");
initForm(toolbar);
</script>
Run Code Online (Sandbox Code Playgroud)
我如何获得与瓦特尔或红宝石的oid值?
我找到了这个宝石:http://watirwebdriver.com/page-performance/
但我似乎无法理解这是什么措施
browser.performance.summary[:response_time]/1000
Run Code Online (Sandbox Code Playgroud)
从第二次打开浏览器开始测量吗?
Watir::Browser.new :chrome
Run Code Online (Sandbox Code Playgroud)
还是从最后的Watir-webdriver命令写的?
我怎样才能启动计时器?
**我已经尝试了几个脚本,但我一直都会得到0 seconds
这就是为什么我不确定.**
我在另一个论坛中发现,在watir webdriver中已经弃用了contains_text方法.如果我能找到准确显示webdriver支持的方法的文档,我将会很高兴.你可能会认为http://watirwebdriver.com/会有这个.但是,嗯,没有.
我试图验证链接的文本是否存在于.在单击链接之前,div不可用.单击链接后,可以单击更多链接.下面是单击以显示其他链接后html的样子.
<div class="more-links">
<a href="url">First Link</a>
<a href="url">Second Link</a>
<a href="url">Third Link</a>
<a href="url">Fourth Link</a>
<a href="url">Fifth Link</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我想确定在div出现后确保文本"Third Link"存在.
我试过了,但是watir说它无法找到那个元素.
assert_equal(true, browser.div(:class => "more-links").a(:text => "Third Link"))
Run Code Online (Sandbox Code Playgroud)
我可以找到这个文本,但是非常慢,并且想要指定这个特定的div
browser.text.include?("Third Link")
Run Code Online (Sandbox Code Playgroud)
思考?
我有一个动态创建的页面,并显示带有价格的产品列表。由于它是动态的,因此重复使用相同的代码来创建每个产品的信息,因此它们共享标签和相同的类。例如:
<div class="product">
<div class="name">Product A</div>
<div class="details">
<span class="description">Description A goes here...</span>
<span class="price">$ 180.00</span>
</div>
</div>
<div class="product">
<div class="name">Product B</div>
<div class="details">
<span class="description">Description B goes here...</span>
<span class="price">$ 43.50</span>
</div>
</div>`
<div class="product">
<div class="name">Product C</div>
<div class="details">
<span class="description">Description C goes here...</span>
<span class="price">$ 51.85</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
等等。
我需要对 Watir 做的是恢复带有 class="price" 的跨度内的所有文本,在此示例中:$ 180.00、$43.50 和 $51.85。
我一直在玩这样的事情:
@browser.span(:class, 'price').each do |row|
但没有用。
我刚刚开始在 Watir 中使用循环。感谢您的帮助。谢谢!
如何id='foo'
使用Watir 获取标记元素的实例数?
我有这个:
b = Watir::Browser.new
b.a(:id => 'foo')
Run Code Online (Sandbox Code Playgroud)
那么如何通过索引获取实例数和访问权限,如下所示:
b.a(:id => 'foo', :index => $i) #Here, $i is a variable in a loop
Run Code Online (Sandbox Code Playgroud)
在伪代码中我基本上试图这样做:
num = "number of a tags with id foo"
while $i less than num do
put b.a(:id => 'foo', :index => $i).text into an array
end
Run Code Online (Sandbox Code Playgroud)
我知道如何做以上所有事情除了发现num
.
使用 Ruby selenium-webdriver 3.142.6
\n\n我的测试有效,但在运行开始时它显示警告
\n\nWARN Selenium [DEPRECATION] :driver_path is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.\n
Run Code Online (Sandbox Code Playgroud)\n\n根据 Ruby 文档,Selenium::WebDriver::Service 是一个私有 API。
\n\n在网上搜索与该警告相关的文章,参考了 Capybara、RoR 和 chromedriver-help,但我\xe2\x80\x99m 都没有使用这些内容。我尝试过“gem install webdrivers”,但失败了。
\n\n关于采取的路径有什么建议:忽略弃用消息,或使用私有 Service 类(如果是的话如何使用它),或尝试用 webdrivers 替换 selenium-webdriver,或其他什么?
\n\n这是成功创建 Selenium 驱动程序的代码,但出现警告
\n\nrequire "selenium-webdriver"\nrequire "test/unit"\nrequire "byebug"\n\n...\n\nclass GoogleTest < Test::Unit::TestCase\n\n def setup\n\n case $browser_arg\n when \'chrome\'\n browser = :chrome\n driver_path = \'/selenium_browser_drivers/chromedriver\'\n when \'firefox\'\n browser = :firefox\n driver_path = \'/selenium_browser_drivers/geckodriver\'\n else\n raise ArgumentError.new("Unexpected browser argument \'#{$browser_arg}\'") …
Run Code Online (Sandbox Code Playgroud) 在同一次运行中执行多个测试时,我发现我得到的错误比我逐个执行测试的错误要多.当我研究这种行为时,我希望通过运行执行我想要的测试的rake任务来获得更准确的结果,但是在新的浏览器实例上运行每个测试,就像我逐个执行它们一样.通过这种方式,我可以获得与手动操作相同的结果,但避免了必须在终端上逐个启动它们的麻烦.
我在文档中搜索过这个功能但是找不到它,我在StackOverflow上发现的唯一类似的问题与selenium有关,而不是watir.
有可能做我正在寻找的事情吗?怎么样?
谢谢.
我正在尝试使用Watir抓取页面上的特定链接:
我的猜测是我需要指定祖先元素biz-website
(?)然后遍历到a
标记并href
以某种方式获取它,但我不确定我的代码的语法需要做什么.
任何想法或提示?