watir-webdriver

Watir-webdriver: how to change attribute value without js/jquery

☆樱花仙子☆ 提交于 2019-12-10 16:46:39
问题 How can I change a href attribute value using watir-webdriver without using js/jquery? I can get an attribute value: @browser.frames[2].div(:id,"mid-2").link(:class,"btn-lrg").attribute_value("href") But I also need to change a bit of the href attribute value. 回答1: I think that the only way to modify the link is to use javascript. The code is quite maintainable since the element is retrieved using watir. #Get the first link (or any element you want) element = browser.frame.link #Check element

How to add a proxy with auth to ChromeDriver on Watir

偶尔善良 提交于 2019-12-10 15:18:38
问题 I'm using Watir on Ruby which uses Selenium as its underlying framework. I'm using ChromeDriver, and to set up a proxy I sually did this: b = Watir::Browser.new :chrome, :switches => ["--proxy-server=11.1.1.11:3011"] Sometimes, the proxy comes with user,password authentication like this: 11.1.1.11:3011:3011:user:pass but when I try to put that string into --proxy-server I get an error. How can I configure ChromeDriver to use the authentication? I've tried the format often suggested in other

Problem running watir-webdriver on Windows 7 with IE9

杀马特。学长 韩版系。学妹 提交于 2019-12-10 14:14:07
问题 I'm trying to use watir-webdriver with IE9 on 64bit Windows 7. When I try to open a new browser I am getting the following error message, any ideas on a solution? C:\watir>irb irb(main):001:0> require "rubygems" => true irb(main):002:0> require "watir-webdriver" => true irb(main):003:0> browser = Watir::Browser.new(:ie) Selenium::WebDriver::Error::NoSuchDriverError: Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones.

Selenium WebDriver Change Firefox path to Tor

折月煮酒 提交于 2019-12-10 11:27:03
问题 I'm trying to change webdriver in ruby to open a tor browser instead of the default firefox broswer. I'm using the following code and I have a tor browser open before I run this code. path='C:\Users\Bonnnie\Downloads\Tor Browser\App\tor.exe' Selenium::WebDriver::Firefox.path = path driver = Selenium::WebDriver.for :firefox I get the following error: unable to obtain stable firefox connection in 60 seconds I think I might be linking to the wrong tor file. 回答1: The following worked for me with

Selenium or Watir Webdriver, how to save resized screenshot?

半城伤御伤魂 提交于 2019-12-08 19:34:30
I try to get a resized 400x400 screenshot of google. I try this both in Selenium and Watir with no success. require 'watir-webdriver' b = Watir::Browser.new b.goto 'google.com' b.window.resize_to(400,400) b.driver.save_screenshot("screenshot.jpg") I always get the screenshot with the original browser size. Any idea how can I save it resized to 400x400? At present, WebDriver defines a screenshot as a "full page screenshot". That is, the entire DOM should be represented by the image generated by the save_screenshot method. The fact that the Chrome driver doesn't generate a screenshot of the full

Selenium or Watir Webdriver, how to save resized screenshot?

柔情痞子 提交于 2019-12-08 03:48:15
问题 I try to get a resized 400x400 screenshot of google. I try this both in Selenium and Watir with no success. require 'watir-webdriver' b = Watir::Browser.new b.goto 'google.com' b.window.resize_to(400,400) b.driver.save_screenshot("screenshot.jpg") I always get the screenshot with the original browser size. Any idea how can I save it resized to 400x400? 回答1: At present, WebDriver defines a screenshot as a "full page screenshot". That is, the entire DOM should be represented by the image

Edge browser crashing after initial watir-webdriver launch

落花浮王杯 提交于 2019-12-08 03:15:10
问题 I'm using the latest selenium-webdriver (2.47.1) and watir-webdriver (0.8.0) and have the Edge WebDriver installed in the Ruby/bin folder like other webdriver.exe files; like chromedriver or iedriver. It appears to launch the Edge browser but does not attempt to goto the URL before closing the browser out and failing all of my tests. I have it allowed by the Firewall within Windows, when i run my rspec tests it states: Selenium::WebDriver::Error::NoSuchWindowError: no such window Has anybody

watir print/put all visible links

北战南征 提交于 2019-12-08 01:59:27
问题 $browser.links.each do |link| puts link.attribute_value("class") end How do I get all the visible/existing links in the put statement? 回答1: You can also write it by using shorter syntax like this: puts $browser.links.find_all(&:present?).map(&:class_name) 回答2: This will output value of class attribute for all existing links on the page: $browser.links.each {|link| puts link.attribute_value("class")} This will output value of class attribute for all visible links on the page: $browser.links

Chrome browser opens and closes using watir webdriver

半腔热情 提交于 2019-12-07 23:00:03
问题 I have the following code: require "rubygems" require "watir-webdriver" browser = Watir::Browser.new(:chrome) browser.goto "http://google.com" When i run this code, the browser opens the site google.com and then closes automatically Why does it close automatically? My chrome version is 12.0.742.68 回答1: The Chrome driver will close all browser instances when your program exits. It's a known issue, and its priority was fortunately bumped today - look for a fix soon. 来源: https://stackoverflow

How to access the <body> tags using watir

倖福魔咒の 提交于 2019-12-07 21:49:06
问题 I am trying to compose an email through watir. So when I trying to access it, it has the <body> tag. Can anyone suggest how to access it? My system configurations IE-8Inter code here Windows-7 I did the following require 'rubygems' require 'watir' @ie.text_field(:id,':13r').set 'sample' HTML CODE <iframe tabIndex="1" class="Am Al editable" id=":13s" src="" frameBorder="0" style="padding-bottom: 0px; background-color: white; padding-left: 0px; padding-right: 0px; height: 248px; overflow: