watir

Cannot create firefox browser with watir-webdriver

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 07:46:37
问题 I have firefox 20 which works with my version of watir-webdriver. I use the following code which can open any browser or a headless phantomjs browser. Chrome and phantom work, but firefox throws an exception. Why? How do I fix this ? require 'rubygems' require 'watir-webdriver' require 'phantomjs' def get_browser(browser_name) browser = nil if browser_name != nil puts "\n#{browser_name} created\n" browser = Watir::Browser.new browser_name.to_sym else puts "creating phantom browser !" browser

Watir How to get rows with different classes

空扰寡人 提交于 2019-12-13 06:05:20
问题 I need to get all rows with class named 'odd_row' or 'even_row'. HTML: <tbody> <tr class="first_row"> … </tr> <tr class="subjectField" style="display:none"> … </tr> <tr class="odd_row"> … </tr> <tr class="subjectField" style="display:none"> … </tr> <tr class="even_row"> … </tr> <tr class="subjectField" style="display:none"> … </tr> </tbody> I tried this: @b.table(:class => 'color_table').tbody.trs(:class => ('odd_row' || 'even_row').size But it returns 1. Does anybody know how to solve this

require 'watir-webdriver' error

怎甘沉沦 提交于 2019-12-13 05:52:30
问题 I am trying to use Watir with Rails, and installed it, and when I use it from irb, it works fine. But when I try to include it in rails application, as require 'rubygems' require 'watir-webdriver' I get the following error: LoadError (no such file to load -- watir-webdriver) Some people had experienced the same problem, which was solved by using require 'rubygems', butin my case, the problem still persists. Any idea? 回答1: Did you add gem 'watir-webdriver' to your Gemfile in Rails root folder?

How can I get some particular link form the links collection

流过昼夜 提交于 2019-12-13 04:37:52
问题 I'm using watir-webdriver have several lines of the same code shown below: ... <p class="schedule-text"> by <a href="http://www.somesite.com">MarketingClub</a> in <a href="http://www.somesite2.com">Marketing</a> </p> I need to get the first links included in p tag and the second links included in p tag so using page object I've added the following code: links(:followees_category, :css => "#home-followees li.animate-in ul li[data-show-id] p.schedule-text a") ... followees_category_elements

How to add text to any html element?

十年热恋 提交于 2019-12-13 02:23:18
问题 I want to add text to body element but I don't know how. Which method will work on the body tag? Sorry for my english and thanks for replies. 回答1: In Watir, you can manipulate a web page (DOM) using JS, just like that: browser.execute_script("document.getElementById('pageContent').appendChild(document.createTextNode('Great Success!'));") I assume that the point of the question is: All users are not just interacting by just clicking buttons and links on the web app, some of them are doing

How do I retrieve a custom attribute in watir?

流过昼夜 提交于 2019-12-13 02:15:58
问题 I'm trying to retrieve the "onclick" attribute value from the below link: <a onclick="test" href="myurl">aaa</a> Using link.href works fine (So I know link is the correct object) however when using link.attribute_value("onclick") what I get is a win32 object (puts shows #<WIN32OLE:0x2cbdf10> instead of the "test" string). 回答1: If you don't get a neater solution, and it's a one off(If you can make sure the development process keeps this kind of testing in mind next time).Try: onclick_value

Watir text box input not persisting after submitting form (resetting to previous text box input)

限于喜欢 提交于 2019-12-13 01:27:45
问题 I'm doing a bit of scraping on this website: http://onthemap.ces.census.gov/ Here's the setup to my code that precedes the error: sample_address = "1600 Amphitheatre Pkwy, Mountain View, CA 94043" b= Watir::Browser.new :chrome b.goto "http://onthemap.ces.census.gov" b.text_field(:id => "search_value").set sample_address b.span(:id => "search_button_label").click Watir::Wait.until { b.a(:text => "Geocoder Results").exists? } address_selector = sample_address.split(" ")[0..1].join(" ") b.a(

Watir-webdriver timing out when asked if element is present?

做~自己de王妃 提交于 2019-12-12 17:20:26
问题 Ruby 1.9.3p327 watir-webdriver 0.6.1 On a fresh Ruby install, with a fresh webdriver install, I am unable to use wait or present? with nonpresent elements without causing non-Watir Timeout errors. In the below example, id 'gb_32' is on the page, but hidden. Id 'gb_50000' does not exist. In both cases "present?" should return false, but the second one gives me a timeout error after 60 seconds. Any ideas why this could happen? irb(main):014:0> b.link(:id,'gb_32').present? => false irb(main):015

Element is not clickable error Ruby / Watir

无人久伴 提交于 2019-12-12 14:37:14
问题 In my test, I am attempting to hit etsy.com, do a search, click on a result, and add the item to my cart. I'm able to do everything up until the point where I attempt to click on the 'add to cart' button. The code below actually works in the IRB so I know my locator is solid, but when I run the test I get an element is unclickable at point error C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/response.rb:71:in 'assert_ok': unknown error: Element

Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Element cannot be scrolled into view:[object HTMLSpanElement]

社会主义新天地 提交于 2019-12-12 14:14:29
问题 Something strange is happening on this page: require "watir-webdriver" b = Watir::Browser.new b.goto "http://mideastunes.com/" b.div(class: "feat-container").element(css: "a span").present? => true b.div(class: "feat-container").element(css: "a span").click Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Element cannot be scrolled into view:[object HTMLSpanElement] from /Users/zeljko/.rvm/gems/ruby-1.9.2-p290@gretel/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/response