watir-webdriver

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:

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:

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

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

How do I get watir-webdriver to start Firefox 4 with Firebug?

本小妞迷上赌 提交于 2019-12-03 15:18:16
Any ideas? I've tried setting webdriver.firefox.useExisting=true as described in the link below hoping to reuse an existing window with firebug enabled, but no such luck. http://code.google.com/p/selenium/wiki/FirefoxDriver you have to create a specific profile where Firebug is always enabled, then launch firefox with this profile in your configuration The quick answer is: browser = Watir::Browser.new(:firefox, :profile => "default") But if you are running tests you probably shouldn't use the default profile. profile = Selenium::WebDriver::Firefox::Profile.new profile.add_extension "/path/to

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

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

how to find best matching element in array of numbers?

怎甘沉沦 提交于 2019-12-03 10:03:14
问题 I need help with something that seems simple but confuses me. Trying to write some fuzzy matching method that copes with differences in format between what value is computed as needed, and which are actually available from a selection list. The value (option strike price) is always a computed Float like 85.0 or Int. The array contains numbers in string form, unpredictable in either increment or whether they will be shown rounded to some decimal (including extra zeros like 5.50 ) or no decimal

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