watir

How to block images in Watir?

此生再无相见时 提交于 2019-12-07 11:55:25
问题 I am using Watir for a data fetching job where I don't need any images to be loaded. Is it possible to block them? 回答1: Disable displaying images in the browser Watir drives manually, and then run Watir script. As far as I know, you can not do it from Watir itself. 回答2: I think it can be: profile = Selenium::WebDriver::Chrome::Profile.new profile['webkit.webprefs.loads_images_automatically'] = false @browser = Watir::Browser.new :chrome, :profile => profile See: http://watir.github.io/docs

How to download a file using Watir 6.0

早过忘川 提交于 2019-12-07 01:05:30
I'm trying to download a CSV file with the new Watir 6.0. I found the profile settings for Firefox: profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.folderList'] = 2 profile['browser.download.dir'] = path_to_download profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv" browser = Watir::Browser.new :firefox, :profile => profile But Firefox 50.0 doesn't support loading profile settings. I get this error message: /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/w3c_bridge.rb:80:in `initialize': unknown option: {:profile=>#

gem install watir not working

余生长醉 提交于 2019-12-06 15:24:49
问题 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

Watir Web driver to download file

依然范特西╮ 提交于 2019-12-06 14:24:42
问题 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. 回答1: 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'] =

Ruby Watir — Trying to loop through links in cnn.com and click each one of them

岁酱吖の 提交于 2019-12-06 14:13:10
I have created this method to loop through the links in a certain div in the web site. My porpose of the method Is to collect the links insert them in an array then click each one of them. require 'watir-webdriver' require 'watir-webdriver/wait' site = Watir::Browser.new :chrome url = "http://www.cnn.com/" site.goto url box = Array.new container = site.div(class: "column zn__column--idx-1") wanted_links = container.links box << wanted_links wanted_links.each do |link| link.click site.goto url site.div(id: "nav__plain-header").wait_until_present end site.close So far it seems like I am only

Watir-webdriver - Select a list display style: none

喜夏-厌秋 提交于 2019-12-06 09:52:23
问题 Hi guys i've been trying to find a solution to my problem everywhere and can't find them. I need to select a value from the second select in this html code, the one that has name="update_status[5955483]" and i don't know how. What i've tried without success. Watir: 1- browser.select_list(:name, "update_status[5955483]").select_value("A") 2 - input_field = browser.div(:class => 'minict_wrapper orange') input_field.link(:name => 'update[5955483}]' ).click 3 - browser.input( :value, "B").click

watir print/put all visible links

匆匆过客 提交于 2019-12-06 09:46:54
$browser.links.each do |link| puts link.attribute_value("class") end How do I get all the visible/existing links in the put statement? You can also write it by using shorter syntax like this: puts $browser.links.find_all(&:present?).map(&:class_name) This will output value of class attribute for all existing links on the page: $browser.links.each {|link| puts link.attribute_value("class")} This will output value of class attribute for all visible links on the page: $browser.links.each {|link| puts link.attribute_value("class") if link.visible?} If you require the class name of the links, you

Selenium WebDriver Change Firefox path to Tor

爷,独闯天下 提交于 2019-12-06 09:34:48
I'm trying to change webdriver in ruby to open a tor browser instead of the default firefox broswer. I'm using the following code and I have a tor browser open before I run this code. path='C:\Users\Bonnnie\Downloads\Tor Browser\App\tor.exe' Selenium::WebDriver::Firefox.path = path driver = Selenium::WebDriver.for :firefox I get the following error: unable to obtain stable firefox connection in 60 seconds I think I might be linking to the wrong tor file. The following worked for me with selenium-webdriver 2.48.1 and Tor Browser Bundle 5.0.3 on Ubuntu Linux 15.04. require 'selenium-webdriver'

How do I scrape data from a page that loads specific data after the main page load?

不羁的心 提交于 2019-12-06 09:09:33
问题 I have been using Ruby and Nokogiri to pull data from a URL similar to this one from the hollister website: http://www.hollisterco.com/webapp/wcs/stores/servlet/TrackDetail?storeId=10251&catalogId=10201&langId=-1&URL=TrackDetailView&orderNumber=1316358 My script looks like this right now: require 'rubygems' require 'nokogiri' require 'open-uri' page = Nokogiri::HTML(open("http://www.hollisterco.com/webapp/wcs/stores/servlet/TrackDetail?storeId=10251&catalogId=10201&langId=-1&URL

How to send text to a CKEditor WYSIWYG editor box using Watir-WebDriver

筅森魡賤 提交于 2019-12-06 08:59:46
问题 I have a watir-webdriver script that sets a CKEditor box using the code below, but this only works with Firefox on Mac OSX when I focus on the screen. For example, if I focus away and let this script run in the background, the text is not entered (but no exception or error is raised). Anyone know how to always ensure it is set? require "watir-webdriver" b = Watir::Browser.new :firefox b.goto "http://ckeditor.com/demo" b.frame(:title => 'Rich text editor, editor1, press ALT 0 for help.').send