watir

Save screenshot with Watir

女生的网名这么多〃 提交于 2019-12-03 17:29:34
I am using Watir with Ruby on Rails. I need to save screenshots of couple of pages using Watir. I have managed to get the page that I want to open to show in a browser, but cannot save the screenshot yet. Here's my code: @browser = Watir::Safari.new folios_screenshot_path = Rails.root.join('screenshots/') @page = Page.find(5) cur_url = root_url + 'pages/' + @page.id.to_s @browser.goto cur_url @browser.div(:id => "page").wait_until_present @browser.driver.save_screenshot(pagess_screenshot_path + '/' + @page.id.to_s + '.png') @browser.close In the page that I load, there's a div element with id

Heroku: unable to connect to chromedriver 127.0.0.1:9515 when using Watir/Selenium

a 夏天 提交于 2019-12-03 17:07:43
问题 This runs locally (without specifying driver_path ), but not on Heroku. Code: Selenium::WebDriver::Chrome.driver_path = ENV['GOOGLE_CHROME_SHIM'] browser = Watir::Browser.new :chrome I've confirmed below values in heroku rails console ENV['GOOGLE_CHROME_BIN'] => "/app/.apt/opt/google/chrome/chrome" ENV['GOOGLE_CHROME_SHIM'] => "/app/.apt/usr/bin/google-chrome-stable" Installed Buildpacks: https://github.com/heroku/heroku-buildpack-chromedriver https://github.com/heroku/heroku-buildpack-google

How to find the data-id in watir?

孤街浪徒 提交于 2019-12-03 15:56:11
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? 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 can get the div using the following (note the format of the locator for the attribute: data-loc-type -> :data

Save image in watir-webdriver

时间秒杀一切 提交于 2019-12-03 15:07:45
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-sUrHLj3D2DrUYNNg4uvr2BNgZqlK5vpJUJVYkkWo36I4RRmRGkYZru5kBYhzPCCn49KlH6wW_iLw6vIzv7vnhpu6ndqxb-9SkIRrVYyBwN39kg18Lov7Hc"> </div> and

watir - installation

笑着哭i 提交于 2019-12-03 13:34:54
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/gems/2.0.0/gems/watir-4.0.2/lib/watir/loader.rb:48:in `load_driver' from C:/Ruby200/lib/ruby/gems/2.0

How to get the number of elements having same attribute in HTML in Watir?

我是研究僧i 提交于 2019-12-03 13:21:47
I have a HTML document which contains elements having the same class name. I could just do an iteration over all the elements in a page and store with elements with a class name in a list. Is there a better way in Watir to get a count of all the HTML elements having the same class name? This question Count of Elements with same attribute in XML kind of addresses the issue, but I had two queries related to that What if the HTML document is not a strict XHTML document? What happens if different types of HTML elements have the same class? Sample HTML files could be: Elements of the same type

Make headless browser stop loading page

空扰寡人 提交于 2019-12-03 12:52:09
I am using the watir-webdriver ruby gem. It starts the browser (Chrome) and begins to load a page. The page is loading too slowly, and watir-webdriver raises a timeout error. How can I make the browser stop loading the page? require 'watir-webdriver' client = Selenium::WebDriver::Remote::Http::Default.new client.timeout = 10 @browser = Watir::Browser.new :chrome, :http_client => client sites = [ "http://google.com/", "http://yahoo.com/", "http://www.nst.com.my/", # => This is the SLOW site "http://drupal.org/", "http://www.msn.com/", "http://stackoverflow.com/" ] sites.each do |url| begin

Compile ruby script into exe?

烈酒焚心 提交于 2019-12-03 11:42:17
问题 Is it possible to compile a ruby script into an .exe on Windows? I have searched everywhere and I've tried the following (It looked like RubyScript2EXE, Shoes and Crate all seemed dead or abandoned.): http://ocra.rubyforge.org/ http://exerb.sourceforge.jp/index.en.html I'm using Ruby 1.8.7 on Windows 7 Ultimate (64bit.) from a clean system I do this: Install RubyInstaller 1.8.7-p358 from rubyinstaller.org gem install watir gem install ocra git clone git://github.com/snaury/exerb-mingw.git cd

how to scroll a web application in watir

你。 提交于 2019-12-03 10:06:38
问题 How do I scroll a web application in Watir ? I have tried @browser.send_keys :space This just brings the whole page down. But I have a scroll within the application, I need to scroll the vertical scroll bar down & up in my automation testing, Please help me ! Thanks! <div dojoattachpoint="containerNode" class="containerNode tabContentPane typeNavigationSingleChild" style="overflow: auto; left: 5px; top: 10px; width: 1549px; height: 535px;"> <div pageid="lifecycle_theme_home_page_dashboard

how to scroll a web page using watir

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 06:38:13
I am trying to scroll a web page to find and click on a content that is lazily loaded when the page is scrolled. I am using following command require 'watir-webdriver' @browser = Watir::new :firefox @browser.send_keys :space I am using web-driver with firefox and I am on ubuntu but it is not working. In the following ruby code I am trying to scroll the page down until I don't find the element with :id. The element is loading lazily. I am getting timeout after few seconds, any idea what is wrong with the following code. When /^deal (\d+) is loaded$/ do |id| (0..5).each do |click| @browser.send