watir

how to exactly match using :class selector in watir-webdriver

蓝咒 提交于 2019-12-12 14:05:00
问题 Regarding the backwards-incompatible change of Watir 0.5.x Finding elements by :class now matches partial class attributes. How do I get the old behavior? I.e. to match exact class name. It is breaking my code, in one case: # expand all multiple records while $browser.div(:class => "expander").exists? $browser.div(:class => "expander").click end because once .click ed, the div 's class becomes "expander hasChildren" (and possibly other classes, depending on table row's color and content). Is

How to open pdf in chromedriver 2.15 without downloading it

二次信任 提交于 2019-12-12 11:50:23
问题 I recently upgraded to Chromedriver 2.15 Now, when I click a link to a pdf file it is auto-downloading instead of displaying in a new tab as before. <a id="my_pdf_file" format="pdf" target="_blank" href="/my_pdf_file.pdf">My PDF File</a> Is there a way to resume the old behavior of displaying the pdf in a new tab? 回答1: This is currently an open issue with Chrome, not Chromedriver: Unable to open a PDF file in chrome since upgrading to v 42.0.2311.90 At some point between M41 and M42, the

cucumber Couldn't load 2.1/gherkin_lexer_en

心不动则不痛 提交于 2019-12-12 11:20:36
问题 I am getting the following error whenever i run cucumber feature. However, the script works fine but this warning message appears everytime i execute the feature file. What is wrong here? C:\Automation\PickLists\Activities\2.RemoveActivity>cucumber WARNING: cannot load such file -- 2.1/gherkin_lexer_en Couldn't load 2.1/gherkin_lexer_en The $LOAD_PATH was: lib C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/cucumber-1.3.18/bin/../lib C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/builder-3.2.2/lib C:/Ruby21

Best practice to keep common steps of cucumber

无人久伴 提交于 2019-12-12 11:05:20
问题 I'm using cucumber-watir-webdriver with for automation purposes. I have the following directory structure: |features -|feature1 --|1.feature --|step_definitions ---|1.rb -feature2 --|2.feature --|step_definitions ---|2.rb and so on. I need to know what is best practice to reduce redundancy in 1.rb and 2.rb . feature1 and feature2 are completely different so I cannot combine both in one directory. Also there is some part where feature line is same but execution in steps is different so it will

Rails: Proxy Authentication in Watir (Chrome Driver)

拜拜、爱过 提交于 2019-12-12 10:48:29
问题 i've tried to add proxy authentication in chrome webdriver which run on the watir like belows: require 'watir' proxies = ['--proxy-server=185.264.167.184:63109', '--proxy-auth=username:password'] browser = Watir::Browser.new :chrome, :switches => proxies browser.goto(url) when the browser run it still asking me username and password like below: And the question is how to set username and password in chrome driver which run on the watir ? 来源: https://stackoverflow.com/questions/46032288/rails

how to click a link in a table based on the text in a row

邮差的信 提交于 2019-12-12 09:22:14
问题 Using page-object and watir-webdriver how can I click a link in a table, based on the row text as below: The table contains 3 rows which have names in the first column, and a corresponding Details link in columns to the right: DASHBOARD .... Details EXAMPLE .... Details and so on. <div class="basicGridHeader"> <table class="basicGridTable">ALL THE DETAILS: ....soon </table> </div> <div class="basicGridWrapper"> <table class="basicGridTable"> <tbody id="bicFac9" class="ide043"> <tr id="id056">

How to access element using Watir and XPath

孤街醉人 提交于 2019-12-12 08:44:18
问题 I have some HTML that looks like this: <h1 id="header">Header</h1> I would like to click it using Watir and XPath. 回答1: After watir-webdriver 0.5.1 selecting random element with an xpath was updated to: browser.element(:xpath => "//h1[@id='header']").click thanks to: https://groups.google.com/forum/#!topic/watir-general/c6Orvy7Qalw 回答2: browser.element_by_xpath("//h1[@id='header']").click Sources: http://wiki.openqa.org/display/WTR/XPath http://zeljkofilipin.com/2007/07/03/find-element-by

Show searched links url in command line with watir

陌路散爱 提交于 2019-12-12 05:19:07
问题 I am new in Ruby and now i'm trying to use watir. So i need to display all founded urls in my command line. Here is the beginning of my code: browser = Watir::Browser.new puts "1. Entering Google" browser.goto "http://www.google.com" search_text = "text" puts " 2. enter "+ search_text +" in the search text field." browser.text_field(:name, "q").set search_text puts "3. click the 'Google Search' button." browser.button(:name, "btnG").click puts " First 10 links: " Can someone help me? Thanks a

How to access href of array of links in a loop using watir-webdriver

我怕爱的太早我们不能终老 提交于 2019-12-12 04:26:17
问题 I've got an array of certain <a> elements like this: array = browser.as(:class => 'foo') I try to go to the links like this: $i = 0 while $i < num do browser.goto array[$i].href . . . $i += 1 end Which works the for the first loop, but not for the second. Why is this happening? If I do puts array[1].href puts array[2].href puts array[-1].href before browser.goto array[$i].href it shows all the links on the first loop in terminal window. 回答1: Someone who knows this better than I do will need

making 'some_element'.present? in watir wait for less than 5 secs

旧巷老猫 提交于 2019-12-12 02:58:58
问题 How do we make some_element.present? or some_element.visible? wait for less than 5 secs.? Because I think some_element.present? alone will wait for default value of 30 secs before timing out. Thanks 回答1: I believe you are asking how to shorten the length of time before timeout, by default its set to 30 seconds, see below on how to customize that time. According to http://watirwebdriver.com/waiting/ Explicit waits There are four built in methods that you can use to make your waiting experience