watir

Can we using regular expression in xpath value?

戏子无情 提交于 2019-12-06 02:48:59
问题 Can we using regular expression in xpath value? I am using xpath value to identify an element on web for automation. I have following :xpath value. :xpath,'//*[@id="ngdialog4"]/div[2]/div[2]/table/tbody/tr/td[1]/input' But, the last digit 4 ngdialog4 is not constant and it keeps on changing each time i open pop-up... can i use some regular expression to match any digit? 回答1: You could have theoretically used matches() , but it is a part of xpath 2.0, which webdriver doesn't support, see a

Is there a chrome switch to suppress 'external protocol request'?

a 夏天 提交于 2019-12-06 01:41:45
问题 Is there a chrome switch to suppress 'external protocol request' ? I am automating an application using selenium - ruby - watir webdriver. I searched over net for solutions to bypass this window and conversation: http://productforums.google.com/forum/#!topic/chrome/K22hXwRy6zQ gives an overview on how we can do that manually. But for Selenium-Chrome-Ruby, I need to do this by probably setting a chrome switch (List of chorme switch:= http://src.chromium.org/svn/trunk/src/chrome/common/chrome

Mouse movement / mouseover and JavaScript evaluation in watir

空扰寡人 提交于 2019-12-05 22:14:18
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? For the first question: browser.div(:id, "some-id").fire_event "onmouseover" I have no idea how to solve the second question. You could ask at watir-general . You can look

Controlling new tab to operate using Watir? (Ruby)

為{幸葍}努か 提交于 2019-12-05 20:38:01
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? 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(:id => "close").click end More information: http://watirwebdriver.com/browser-popups/ You can use this code

watir-webdriver change proxy while keeping browser open

狂风中的少年 提交于 2019-12-05 18:50:17
I am using the Watir-Webdriver library in Ruby to check some pages. I know I can connect through a proxy using profile = Selenium::WebDriver::Firefox::Profile.new#create a new profile profile.proxy = Selenium::WebDriver::Proxy.new(#create proxy data for in the profile :http => proxyadress, :ftp => nil, :ssl => nil, :no_proxy => nil ) browser = Watir::Browser.new :firefox, :profile => profile#create a browser window with this profile browser.goto "http://www.example.com" browser.close However, when wanting to connect to the same page multiple times using different proxies, I have to create a

Watir-webdriver throws 'not clickable' error even when element is visible, present

你。 提交于 2019-12-05 12:45:47
I am trying to automate tests in Ruby using the latest Watir-Webdriver 0.9.1 , Selenium-Webdriver 2.53.0 and Chrome extension 2.21 . However the website that I am testing has static headers at the top or sometimes static footers at the bottom. Hence since Watir auto-scrolls an element into view before clicking, the elements get hidden under the static header or the static footer. I do not want to set desired_capabitlites (ElementScrollBehavior) to 1 or 0 as the websites I am testing can have both - static header or static footer or both. Hence the question are: 1) Why does Watir throw an

Auto Download files in watir

∥☆過路亽.° 提交于 2019-12-05 05:05:00
问题 How to auto download the excel files from the browser in one click on the link, without going through the "save as" and other windows in watir. I am trying to keep it OS independent, so would not be interested in using win32ole gem. 回答1: for this task I tweaking my profile preferences my code looks like this: chrome driver: profile = Selenium::WebDriver::Chrome::Profile.new profile['download.default_directory'] = download_directory profile['download.prompt_for_download'] = false browser =

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

隐身守侯 提交于 2019-12-05 04:03:00
问题 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

Save screenshot with Watir

*爱你&永不变心* 提交于 2019-12-05 03:40:54
问题 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

Cucumber embed for screenshots not linking to screenshot

ぐ巨炮叔叔 提交于 2019-12-05 03:27:49
问题 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