watir

Watir webdriver: Doesn't do anything after opening browser (firefox)

删除回忆录丶 提交于 2019-12-18 09:38:52
问题 It was working fine before, now whenever I run the script it just opens Firefox then does nothing. It works when running with chromedriver though. Tried updating gems etc, but no success. 回答1: The latest Firefox version will no longer work with the legacy Firefox Driver. To use Watir with Firefox 48+ you need to download geckodriver and follow the instructions for Ruby. Since Geckodriver is not yet feature complete, you most likely will want to continue using the legacy Firefox Driver, which

How to specify the location of the chromedriver binary

隐身守侯 提交于 2019-12-18 04:02:53
问题 Earlier I had put the Chrome binary, "chromedriver.exe", in the "C:/Windows" directory and Watir was picking it from there. Now I have to move my project to another machine so I can't hardcode the executable path. I also want the binary to be kept with our code on Git rather than making each test engineer manually update the binary as newer versions are released. Now I have placed Chrome binary at a absolute path, but it is not being found. Here is what I tried (hooks.rb): Before do puts

Handling a javascript popup occurring on a keyup event

不问归期 提交于 2019-12-17 20:10:57
问题 I have a text-field on a HTML page which checks whether you have entered a value between 1 to 365. If the user enters an invalid value like a non-numeric character or a value which does not fall inside the range, it shows a popup. I saw on the watir wiki that there is a select_no_wait method which is used to dismiss popups when you select an invalid value from the list. What is a good way to handle a popup occurring on a keyup event? Do i need to proceed along the lines the way select_no_wait

Accessing an element with no attributes in Watir

痴心易碎 提交于 2019-12-17 18:59:22
问题 Using Watir, is there a way to access an element without attributes? For example: <span>Text</span> I'd like to avoid using xpath, but if that's the only way it's cool. 回答1: Disregarding the non-WATIR issues of having tags in the first place, or requesting unique attributes from your developers (or yourself), you can always access an element via its parent elements, or by index. For example: Text @browser.div(:name => "content").span(:index => 1) #this is the first span element inside this

wait_until block is giving time out error

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 21:27:33
问题 This is the code which is failing for me. link(:continue, :text => 'Continue Shopping') def verify_cart wait_until(60) do continue_element.visible? end end To make it work I have tried solutions here: Inconsistently getting error (Watir::Wait::TimeoutError) and Timeout::Error in Rails application using Watir but none worked for me. I have also tried by increasing the time. Then I tried by increasing the at implicit wait from 3 seconds to 20 seconds and instead of using wait_until block I

Select Radio buttons from excel with ruby

此生再无相见时 提交于 2019-12-13 19:29:52
问题 I would like to select radio button from an excel spreadsheet for a data driven test. I have tried the following: radio=worksheet.cells(rows,"A").value browser.radio(:name => 'name').set radio I also tried selecting as a string but got errors: radio=worksheet.cells(rows,"A").value string_from_excel = "set" browser.send string_from_excel, radio the code for the radio button is: <input id="radio" type="radio" onclick="setradio(0)" value="0" name="radio"> Thanks for the help 回答1: First lets try

Default profile name in Chrome when using Watir-Webdriver?

六眼飞鱼酱① 提交于 2019-12-13 15:50:46
问题 I downloaded the Chromedriver then I extracted it to the right place (usr/bin), but I don't know what is the default profile name for the Chrome (Chromium) browser, so this line throw an error message: browser = Watir::Browser.new :chrome, :profile => "default" I tried either "current" or my username instead of "default", but none of them worked. How can I start Chrome with my default profile? Because I don't want to start a new profile without the usual preferences, and saved passwords,

Ruby+Watir测试环境搭建

元气小坏坏 提交于 2019-12-13 15:03:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Windows下搭建Ruby+Watir的环境颇为麻烦,建议使用linux平台,问题会少一点,如果你坚持在windows下面做,请继续往下看: 1、去 rubyinstall 下载对应版本的安装程序,使用rubyinstall能为我们节省不少时间去设置相应的环境变量。(ps:注意尽量ruby的安装路径不要带有空格,避免后期各种不必要的问题。) 2、安装过程就不赘述了,一路点下去就可以了。 3、ruby下安装第三方代码库主要使用gem进行安装,安装前建议先更新gem版本,最新版本的gem能保证在安装第三方库时及时抓取相应的库依赖关系,确保程序正确性,更新代码: gem update --system --no-rdoc --no-ri --no-rdoc --no-ri作用是在发布环境中设置是否同步更新代码库的文档,ri是ruby中的文档查阅工具,rdoc就是相应代码库的文档。 4、关于mysql适配器的安装,ruby下mysql主要有3个连接适配器:mysql、mysql2、do_mysql,网上有篇查询效率的比较(三万行数据的遍历操作) user system total real 0.750000 0.180000 0.930000 ( 1.821655) Mysql2 1.650000 0.200000

Watir question regarding select_list and reloading

若如初见. 提交于 2019-12-13 12:33:29
问题 I have a drop down with multiple options. Whenever you choose an option, the page reloads with data specific with that option. Currently I'm using select.list(:name, strg).set(value) and it does that part just fine, but it does not reload the page with the specific data. Anyone know how to help. When i watch it in action, it doesn't select the option either, but my logs show that it does.Thanks. Edit: Got it to work with fire_event("onclick") 回答1: Without seeing the page, my guess is that you

Watir and the preceding_sibling method hmmm

不打扰是莪最后的温柔 提交于 2019-12-13 11:02:36
问题 Here is my code: #test require 'watir' url_file = "file:///home/alain/yo.html" # same as yo: yo = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <div class="Time">time1</div> <span class="Locus">locus1</span> <span class="Locus">locus2</span> <body text="andale"> <div class="alpha"> <div class="Time">time2</div> <span class="Locus">locus3</span> <div class="Time">time3</div>