watir

How can we get Watir-Webdriver to work with the IE invalid cert screen?

懵懂的女人 提交于 2019-12-04 04:34:07
问题 We've probably all seen this screen when testing, all you need is a HTTPS site with a self signed cert and you get the "There is a problem with this website's security certificate" screen, which requires you to click a link to continue. With Watir this is no problem, I automate the screen as I would any other webpage, clicking the link according to its text or ID value. With Watir-Webdriver it's as if nothing inside the HTML can be recognized. and I'm not alone in this See this question It's

How to access element using Watir and XPath

人盡茶涼 提交于 2019-12-04 04:01:26
I have some HTML that looks like this: <h1 id="header">Header</h1> I would like to click it using Watir and XPath. akostadinov 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 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-xpath/ browser.h1(:xpath, "//h1[@id='header']").click Also not XPath, but works: browser.h1(:html,

Ruby Watir: Clicking OK on JavaScript Alerts?

99封情书 提交于 2019-12-04 03:01:55
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 in the prompts can change, my intention is to hit OK regardless of what is inside the alert/confirm

Watir Webdriver counting number of items in a UL list

£可爱£侵袭症+ 提交于 2019-12-04 02:50:20
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 variable that I can use to exit the loop and do the next thing I want. The HTML is like so: <ul id=

Using Watir to check for bad links

孤街浪徒 提交于 2019-12-04 01:26:55
问题 I have an unordered list of links that I save off to the side, and I want to click each link and make sure it goes to a real page and doesnt 404, 500, etc. The issue is that I do not know how to do it. Is there some object I can inspect which will give me the http status code or anything? mylinks = Browser.ul(:id, 'my_ul_id').links mylinks.each do |link| link.click # need to check for a 200 status or something here! how? Browser.back end 回答1: My answer is similar idea with the Tin Man's.

no such file to load — ffi_c (LoadError)

孤人 提交于 2019-12-04 00:44:51
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_original_require path else spec = Gem.searcher.find_active path unless spec then found_specs = Gem.searcher

How to click on specific element in canvas by its coordinates (using WebDriver)?

无人久伴 提交于 2019-12-03 21:43:36
I have a canvas element on my page and I want to click on specific (x, y) coordinates in this canvas. I use watir-webdriver: element = browser.driver.find_element(:id, 'canvas') browser.driver.action.move_to(element).move_by(x, y).click().perform But this code just clicks on the center of the canvas, not the specified (x, y) coordinates. What is wrong with it? UPD: So now I use this code: element = browser.driver.find_element(:id, 'canvas') browser.driver.action.move_to(element, x, y).perform browser.driver.click.perform But it still clicks on the center of the canvas and not on specified (x,

Turning a select_list options into a string array in watir-webdriver?

柔情痞子 提交于 2019-12-03 21:19:41
I need to check the contents of a select list drop down which varies depending on a value in another field. I am reading the valid options into an array of strings from a CVS field and comparing by doing the following; selectContent = [] $browser.select_list(:id,"srch-status-select").options.each {|option| selectContent << option.text} assert_equal(validContent,selectContent,"Status drop down has wrong values") Is this correct or is there an existing select_list method which does a similar conversion? There's no method doing exactly what you want, but a more concise version would be:

Ruby: Cannot Install Watir Gem On Windows

我是研究僧i 提交于 2019-12-03 21:03:44
问题 Watir's site says I need Ruby 1.8.6, which I'm running. And windows installation should be as simple as gem install watir . But when I run that, I get this: C:\Users\Ryguy\Code>gem install watir Building native extensions. This could take a while... ERROR: Error installing watir: ERROR: Failed to build gem native extension. C:/Ruby/bin/ruby.exe extconf.rb checking for strncpy_s()... no creating Makefile make 'make' is not recognized as an internal or external command, operable program or

Cucumber embed for screenshots not linking to screenshot

微笑、不失礼 提交于 2019-12-03 17:44:55
Cross-posted from the Cukes Google Group: I have experimented with a number of methods of saving screenshots, but settled on the method that is built into watir-webdriver. No matter which method I have used, I am not able to successfully embed a link to this image in the Cucumber HTML report. In c:\ruby\cucumber\project_name\features\support\hooks.rb, I'm using: After do |scenario| if scenario.failed? @browser.driver.save_screenshot("screenshot.png") embed("screenshot.png", "image/png") end end A link with text "Screenshot" IS added to the report, but the URL is the project directory path ("c: