watir-webdriver

Can a watir browser object be re-used in a later Ruby process?

为君一笑 提交于 2019-12-30 10:41:46
问题 So let's say pretty often a script runs that opens a browser and does web things: require 'watir-webdriver' $browser = Watir::Browser.new(:firefox, :profile => "botmode") => #<Watir::Browser:0x7fc97b06f558 url="about:blank" title="about:blank"> It could end gracefully with a browser.close, or it could crash sooner and leave behind the memory-hungry Firefox process, unnoticed until they accumulate and slow the server to a crawl. My question is twofold: What is a good practice to ensure that

Watir+Cucumber Connection refused

巧了我就是萌 提交于 2019-12-25 06:48:15
问题 Folks, I am using watir+cucumber in my tests and for each feature I am reusing the instance of the browser, that is I create the instance of @@browser = Watir::Browser.new and then reuse this through out my tests, I am using watir-webdriver , my tests where running fine till now, I just added another scenario and I consistently get the below error message: Connection refused - connect(2) (Errno::ECONNREFUSED) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb

page-object gem seems not working

泪湿孤枕 提交于 2019-12-25 04:53:15
问题 I am trying to use page-object gem in my watir-webdriver scripts and I think I might be missing something. Here is my code for log_in.rb: require "./all_deals" class LogIn include PageObject text_field(:email, :id => 'UserName') text_field(:password, :id => 'Password') checkbox(:remember_me, :id => 'RememberMe') button(:log_me_in, :value => 'Login') def initialize(browser) @browser = browser end def log_in (email, password) self.email = email self.password = password remember_me log_me_in

continued example - cannot find watir element

坚强是说给别人听的谎言 提交于 2019-12-25 02:57:14
问题 In Cannot click html element with watir, i was trying to click an element which gives me the row below: I am not able to find the three dropdown lists which you see in the image above. How do I do it ? Each time, the id of the dropdown elements changes. For example, the middle one html code is: <td> <select id="filtersJob6_intrinsic_enumOperator" name="filtersJob6_intrinsic_enumOperator" onchange="if(top.document.getElementById('filtersJob6_intrinsic_enumOperator').value=='isNull'||top

Watir-WebDriver: Find elements which class is not 'completed'

匆匆过客 提交于 2019-12-24 09:55:22
问题 I have a bunch of li elements. They are either with uncompleted , 'current' or completed class or without a class. How do I find all li elements without completed class? So far I am doing this by selecting necessary li objects from collection of li (through calling #attribute_value('class') , but maybe there is some elegant locating strategy in Watir-WebDriver? UPD: As long as there is some misunderstanding of the question. I want to know if there is locating strategy within Watir-WebDriver

Can I copy a text on a webpage and paste it in a text file?

天大地大妈咪最大 提交于 2019-12-24 09:15:08
问题 I have a webpage which dynamically displays a text which I want to copy into a text file using watir-webdriver or any other additional gems. Is it possible?? If yes, how?? Thanks in advance.. 回答1: If you are talking about web-scraping try Nokogiri 回答2: I will assume that you you have HMTL like this: <div id="tehcodez">teh codez</div> This would save text teh codez to file tehcodez.txt (not tested): text = browser.div(:id => "tehcodez").text File.open("tehcodez.txt", "w") {|file| file.write

Watir loses browser connection after first goto

限于喜欢 提交于 2019-12-24 07:08:00
问题 I am completely new to Watir, trying to work out the basics so we can use it for testing our websites. The problem is, following the 'Watir in 5 minutes' after I do my first browser.goto , I seem to lose connection to the browser window. The window is still there, but I can no longer "command" it from irb. I just get this error: C:\>irb DL is deprecated, please use Fiddle irb(main):001:0> require "watir-webdriver" => true irb(main):002:0> ie = Watir::Browser.new :ie Started

Remote Watir-Webdriver IE form field not recognizing text and keys

橙三吉。 提交于 2019-12-24 03:25:38
问题 I have been using Cucumber / Watir-Webdriver just fine with IE. In my tests, I go to a form field and enter data and click a save button. All actions work great. Recently I decided to go with Selenium Grid 2 to distribute tests across machines for performance reasons. It worked great with FF and Chrome but I began to see a problem with IE. Here's the problem: when I use Selenium Grid 2 to drive IE remotely, when it sends keystrokes (i.e. send_keys or .set "some string of text") the text is

Ability to launch chrome with extensions loaded with watir-webdriver

五迷三道 提交于 2019-12-23 12:45:09
问题 I'm attempting to launch chrome using watir-webdriver but with a specific extension loaded. I haven't been able to figure out how to do this in ruby. When I run the following code @browser = Watir::Browser.new(:chrome, :switches => %w[--load-extension="file path of the extension"]) I will get this message: Now what I noticed was odd was the dual path. I'm not sure where the first half of the path is coming from ("...Google\Chrome\Application\21..."). The 2nd half of it is what I specified in

How to download a file using Watir 6.0

ぃ、小莉子 提交于 2019-12-23 03:45:08
问题 I'm trying to download a CSV file with the new Watir 6.0. I found the profile settings for Firefox: profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.folderList'] = 2 profile['browser.download.dir'] = path_to_download profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv" browser = Watir::Browser.new :firefox, :profile => profile But Firefox 50.0 doesn't support loading profile settings. I get this error message: /var/lib/gems/2.3.0/gems/selenium-webdriver