watir

How to detect if an element exists in Watir

安稳与你 提交于 2019-12-05 02:34:03
I'm relatively new to Watir but can find no good documentation (examples) regarding how to check if an element exists. There are the API specs, of course, but these make precious little sense to me if I don't find an example. I've tried both combinations but nothing seems to work... if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists then... if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists? then... If anyone has a concrete suggestion as per how to implement this, please help! Thanks! It seems you are missing a comma between

How to find the data-id in watir?

那年仲夏 提交于 2019-12-05 01:40:45
问题 I am new to watir testing. Would somebody help me to find the following element. <div class="location_picker_type_level" data-loc-type="1"> <table></table> </div> I like to find this div , data-loc-type with table exists. ex: browser.elements(:xpath,"//div[@class='location_picker_type_section[data-loc-type='1']' table ]").exists? 回答1: Watir supports using data- type attributes as locators (ie no need to use xpath). Simply replace the dashes with underscores and add a colon to the start. You

Watir Changing Mozilla Firefox Preferences

纵饮孤独 提交于 2019-12-05 01:23:09
问题 I'm running a Ruby script using Watir to automate some things for me. I'm attempting to automatically save some files to a certain directory. So, in my Mozilla settings I set my default download directory to say the desktop and choose to automatically save files. These changes, however, are not reflected when I begin to run my script. It seems like the preferences revert back to default. I've included the following require "rubygems" # Optional. require "watir-webdriver" # For web automation.

Save image in watir-webdriver

送分小仙女□ 提交于 2019-12-04 23:16:11
问题 I need to save image from recaptcha to localhost disk, i'm getting image dom element using watir-webdriver, but it doesn't support save method, as watir do. So how can i save image to my disk? Html: <div id="recaptcha_image" style="width: 300px; height: 57px;"> <img style="display:block;" alt="Проверка по слову reCAPTCHA" height="57" width="300" src="https://www.google.com/recaptcha/api/image?c=03AHJ_VusSUxF0IYURRcVTVTjJJnUk92j-hXYsuwqvu0m5tvKFzAnwvrHlz-j_Gfqg

watir - installation

社会主义新天地 提交于 2019-12-04 22:44:38
问题 I have installed Ruby 2, devkit & Watir. I am getting the following error. Can anyone please help me resolve this issue? C:\devkit>irb DL is deprecated, please use Fiddle irb(main):001:0> require "watir" => true irb(main):002:0> browser = Watir::Browser.new LoadError: cannot load such file -- watir-classic from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in`require' from C:/Ruby200/lib/ruby

how to click on browser “stop loading this page” using ruby watir?

一世执手 提交于 2019-12-04 20:02:14
I want to click on browser "stop loading this page" icon, when timeout error occurs,what should i do for it? Some thing like this: browser.stop # this is wrong. I searched forever and the best I could come up with was: b = Watir::Browser.new b.driver.manage.timeouts.implicit_wait = 3 This worked great for me with firefox. Arup Rakshit The below link may help you : Stop loading page watir-webdriver Is there have method to stop page loading in watir-webdriver Just try this logic when you want to stop the loading, @browser.send_keys :escape It is not the best way of doing what you want but still

gem install watir not working

Deadly 提交于 2019-12-04 19:37:08
C:\DevKit>gem install watir Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing watir: ERROR: Failed to build gem native extension. C:/Ruby192/bin/ruby.exe extconf.rb checking for libxml/parser.h... no ----- libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokog iri.html for help with installing dependencies. ----- *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need

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

China☆狼群 提交于 2019-12-04 19:33:09
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"> <td class="bicRowFac10"> <span> <label class="bicDeco5"> <b>DASHBOARD:</b> ---> Based on this text <

Watir Web driver to download file

拜拜、爱过 提交于 2019-12-04 19:19:43
I'm writing Ruby script to automate Downloading files from a list of files using Watir web driver. Any pointers or approaches on Automating Popping up of Window and Directory Chooser to save the file into a location? Thanks. coloradoblue change default Watir preferences for download location for chrome profile = Selenium::WebDriver::Chrome::Profile.new download_dir = File.join(Rails.root, 'lib', 'assets') profile['download.default_directory'] = download_dir profile['download.prompt_for_download'] = false @b = Watir::Browser.new :chrome, :profile => profile for firefox profile = Selenium:

how to save image in blob field using watir?

邮差的信 提交于 2019-12-04 18:09:40
<table> <tr> <td>hello</td> <td><img src="xyz.png" width="100" height="100"></td> </tr> </table> i want to save this xyz.png in blob form into my db, so how can i save image in blob form. Take a look at this quick example I wrote up. Essentially, I just find the image I want using an id and then get it's source. Then, I open a temp file to hold the contents of the image and finally, I open the url of that src and write it to the temp file. The benefit of using tempfile is there is no cleanup. require 'watir-webdriver' require 'open-uri' require 'tempfile' browser = Watir::Browser.new :firefox