watir

Controlling new tab to operate using Watir? (Ruby)

眉间皱痕 提交于 2019-12-22 10:54:06
问题 I'm using watir for automated testing and after running through some tables, a chart then gets opened up in a new tab. But watir doesn't seem to recognise the new current tab and continues to search through the original browser tab. Is there any way of telling watir which tab you want to be using? 回答1: Watir does not care if a new page opens in a new window or in a new tab, so use window switching API to switch to the new tab: browser.window(:title => "annoying popup").use do browser.button(

Mouse movement / mouseover and JavaScript evaluation in watir

两盒软妹~` 提交于 2019-12-22 09:21:22
问题 I have a JavaScript-heavy Rails app which I am testing in watir. I have two specific testing requirements: I need to be able to simulate moving the mouse to a specific area of the screen (or at least triggering the onmouseover event for a div) Evaluating a snippet of JavaScript once the above has happened to see if a flag is set correctly I haven't been able to figure out how to do this in watir. Any ideas on how to do this? 回答1: For the first question: browser.div(:id, "some-id").fire_event

How to pass browser parameter to Watir

蓝咒 提交于 2019-12-21 19:47:11
问题 I am using Ruby and am using the latest gem version of Watir. I plan to use headless browser such as PhantomJS. How can one pass paramater to the Phantom JS browser when it get executed. My purpose is so that Phantom JS do not need to load images. 回答1: As described on the PhantomJS command line page, there is an option to control the loading of images: --load-images=[true|false] load all inlined images (default is true). Also accepted: [yes|no]. During the initialization of a Watir::Browser,

How to simulate CTRL+Click with watir-webdriver?

寵の児 提交于 2019-12-21 18:47:14
问题 I want to simulate ctrl keydown and ctrl keyup. My use-case is the following: The user can select from a list (build with a table) multiple elements by pressing CTRL key and clicking on the desired row. When the CTRL key is released an AJAX call will be made. I need a watir test to simulate this. How can i do this ? Any ideas ? I would need a solution that works under Linux Thanks a lot. 回答1: I believe the best way to send comands would be to do the following: require 'watir-webdriver'

Ruby Watir: Clicking OK on JavaScript Alerts?

扶醉桌前 提交于 2019-12-21 09:17:48
问题 Seems none of the code I've tried has any affect. My intention is to close any and all JavaScript prompts that may come up by hitting the "OK" button. Problem is, my script has no affect on the prompts that come up. In other words, it does nothing. Here's what I have: fx = FireWatir::Firefox.start(somepage) fx.startClicker("OK") fx.button(:id, "OK").click fx.button(:id, "CONFIRM").click The HTML: <script type="text/javascript"> alert("Alert!"); window.confirm("Confirm?"); </script> The text

Watir Webdriver counting number of items in a UL list

吃可爱长大的小学妹 提交于 2019-12-21 09:08:12
问题 I've done a few searches and I'm unable to find a suitable answer. Basically I have an unordered list which can be of a varying length. I want to iterate through the list, do some other things and then come back and select the next item on the list. I can do this fine when I define the amount of times my loop should iterate as I know the amount of items in the list. However I don't want to define this for each test, I want to grab the number of items in the list and then pop that into a

no such file to load — ffi_c (LoadError)

回眸只為那壹抹淺笑 提交于 2019-12-21 07:28:08
问题 This problem is bugging me for a couple of days now... Whenever I'm using the .bring_to_front method require "rubygems" require "watir" browser = Watir::Browser::new browser.bring_to_front I get this error: (...)rubygems/custom_require.rb:36:in `require': no such file to load -- ffi_c (LoadError) I tried uninstalling and reinstalling ffi/watir/ruby/netbeans without success. line 36 is in custom_require.rb def require path if Gem.unresolved_deps.empty? or Gem.loaded_path? path then gem

Make headless browser stop loading page

自作多情 提交于 2019-12-21 04:19:05
问题 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

How to enter password in a popup using watir?

故事扮演 提交于 2019-12-20 16:49:46
问题 I'm writing some watir test cases: browser.goto "http://egauge2592.egaug.es/" browser.link(:href,"/settings.html").click browser.text_field(:index,4).set("some text") browser.button(:id,"save_button").click then a 'Authentication Required' dialogue opens, asking for username and password . No matter how I tried, I couldn't access the text fields. I tried send_keys and JavaScript. I also tried Watir.autoit but it says undefined method. I'm using watir on a Ubuntu machine with the FireFox

How to use watir-webdriver to wait for page load

谁都会走 提交于 2019-12-20 09:37:34
问题 Using watir-webdriver, how do I wait for a page to load after I click a link? At the moment I am using: sleep n But this is not ideal as the page response varies so much. Is there a way to test whether the page is ready or whether there is a certain element in the page? I understand in the normal Watir gem there is Watir::Waiter.wait_until or something similar, but I don't see this in the webdriver version. 回答1: I don't know if they're the best way, but this is how I'm handling this for