FAQ Database Discussion Community


Set cookie using watir webdriver or selenium

ruby,cookies,selenium-webdriver,watir-webdriver
Creation of driver:- profile = Selenium::WebDriver::Firefox::Profile.new driver = Watir::Browser.new :firefox, profile: profile url= 'http://www.example.com' Adding cookies:- driver.cookies.add("test","1",{expires: 10.days.from_now}) driver.goto url My cookies not returned in the response. If i add domain in cookies. driver.cookies.add("test","1",{expires: 10.days.from_now, domain: 'example.com'}) its saying errors like below:- Selenium::WebDriver::Error::InvalidCookieDomainError: You may only set cookies for the...

Ruby - Active Record Query - Comparing Variables Producing False Positive

ruby,database,activerecord,watir-webdriver
Be warned this a newbie question as its first time using active recored and oracle db.Trying to get my head around active record returned values and its comparison operators. To summarise I want to get a offer id and then compare to the offer value stored in the database and...

Write clickable xpath for entire text in different “span” tags but under one “p” tag

html,ruby,xpath,watir,watir-webdriver
Here's xpath that I wrote but it is of not optimum xpath expression, I think. //div[contains(@class,'config')]/a[contains(.,'student')]/../p[contains(.,'Never logged as ') and contains(.,'admin')] HTML is this: <div class="config"> <a class="something student something " href="something" htmlelement = "something"> <div class="bla bla"/> <div class="bla bls> xyz </div> <div class="bla blab">abc</div> <span>Allow it</span> </a> <p>...

Custom screeshot for watir-rspec reporter

rspec,watir,watir-webdriver
I am migrating from watir-webdriver with rspec to watir-rspec (not a big change). But now I want to make use of the reporter to link the screenshots I take with the screenshot gem. I am struggling on how to to this and I don't want to use the standards screenshots...

Clicking on Anchor Tag with Button Role

html,ruby,watir,watir-webdriver
I have a URL that I'm trying to extract information from. I want to navigate to a certain anchor tag that has a class value "_g3j", and click on it (it has a button role). I'm not sure how to access it and use the click method. That click would...

Can't execute 'onclick' using 'fire_event'

ruby,cucumber,watir,watir-webdriver,page-object-gem
I have a div menu which is hidden. Div includes a span with onclick: onclick="parent.ClickMenuItem(this, '', 'http://some_link', 0); parent.wndPopupbtnMenu.hide(); When I try to execute it via fire_event nothing happens. But step becomes to passed. page.spnMngUsers_element.fire_event :onclick Page object of spnMngUsers: in_iframe(:id => 'PortalSubmenuFrame') do |frame| span(:spnMngUsers, :xpath => "//span[text()='Users']", :frame...

Watir-Webdriver EOFError and Errno::ECONNREFUSED

firefox,selenium,webdriver,watir-webdriver,headless
While running a DelayedJobs queue that uses Watir-Webdriver (with Headless and Firefox) to get some data off the web a few times per hour, I am encountering random EOFError and ECONNREFUSED errors. It's a reasonably simple script that goes to a site, logs in, enters data in a form and...

Unable to locate nested p element

ruby-on-rails,rspec,watir,watir-webdriver,page-object-gem
How would I locate the "tile" element in the HTML: <div class="con-head"> <div class="up-at js-con-dates"> <span class="bold">Last date</span> 7:13 PM <br> <span class="bold">Save</span> 7:12 PM </div> <p class="tile">Text: Kids </p> <p class="desc js-desc" style="">Q&A </p> </div> I tried to locate it with the accessor: div(:my_title) { div_element(:class => 'con-head').div_element(:class =>...

Parallel-test Cucumber watir testing with phantomjs ECONREFUSED

cucumber,phantomjs,watir,watir-webdriver
I`m having issues with phantomjs with my parallel testing, firefox is running fine. I use parallel_tests, watir-webdriver, and Cucumber. No connection could be made because the target machine actively refused it. - connect(2) for "127.0.0.1" port 8910 (Errno::ECONNREFUSED) Tests are running via: parallel_cucumber features/parallel_tests -n 3 After some debugging I...

How to pick values from inside a span using ruby watir?

ruby,watir-webdriver
I am new to ruby-watir test automation. I intend to read the value '$9,118 per week'for verification HTML <p class="inline-result">Your repayments will be: <span>$9,118 per week</span></p> Any ideas?...

Watir & Nokogiri not loading content in frame

watir,watir-webdriver
Using watir & nokogiri to parse the content I can find in my bank account. The line browser.div(:id => 'main_layout_v2_1_cell_1:0').wait_until_present tells watir to wait until the div that is loaded by js appears. (I disabled javascript in Chrome to check if the content is loaded by javascript, and indeed it...

Ruby Watir to get specific html element of a page

ruby,watir,watir-webdriver
I have already try this one: puts browser.text and it works. I would like to ask if it is possible to display or print only the specific element or html tags. For example this one: <button class="btn btn-add" data-role="add">Add New User</button> Is there any way to get this element only?...

How can page-object-gem be used with IRB?

ruby,selenium-webdriver,watir-webdriver,page-object-gem
Using watir-webdriver, you can test your code while developing using IRB (interactive ruby). But this does not seem to work when using the page-object gem. When I run the ruby program, I can see my page-object calls are working. This is not apparent from IRB. E.g. Here's what I type...

Use page-object gem to check a box in a table

watir,watir-webdriver,pageobjects,page-object-gem
My page has a table with a checkbox in the first column. I want to check the box in each row up to a given number. I can do this in watir-webdriver, but not with page-object; possibly due to the HTML structure. HTML - edited for relevancy (there is more...

Interact with a file_field inside span - Watir/Selenium-Webdriver

ruby,selenium-webdriver,watir-webdriver
How do I interact with a file_field thats hidden by its parent? <span class="btn button-large fileinput-button"> Select files... <input accept="image/png, image/gif, image/jpeg" id="gallery_files" multiple="multiple" name="gallery_files" type="file"> </span> The button overlays the input, therefore it's not visible. Edit For the record, here's my code: data[:photos].each do |photo| $browser.file_field.set photo end and...

Watir select option not in list

watir,watir-webdriver,selectlist
I'm using watir to test/run through my site. I'm wondering if it is possible to use watir to set the value of a select list that is not on the options list. I've noticed that with Ruby Mechanize you can simply set the value of the field, but it is...

Access to page methods within section

ruby,watir-webdriver,page-object-gem
Now sections are threaded as elements with some other elements in it but this approach makes unable to use page methods inside sections: wait_until { login_button? } will raise NoMethodError: undefined method 'wait_until' for Watir::HTMLElement Is there anyway to access page methods inside section class?...

watir method conflicts with my ruby class

ruby,watir,watir-webdriver,nomethoderror
Hi guys i'm doing some automations scripts with Watir and trying to create a ruby class to make it better but i'm having this error: examen.rb:6:in 'enterEmail': undefined method 'text_field' for # (NoMethodError) This is part of my conflictive code: require 'watir-webdriver' class LoginPage def enterEmail (email) text_field(:user, :id =>...

How to get list label text using watir

ruby,watir-webdriver
I am trying to use WATIR to automate testing of a web application. I have the application functionality working but am struggling on the login page as it requests two questions to provide random characters from the passphrase. In the code snippet below this is requesting characters 8 and 1....

Developers tool(F12) is opening in Internet Explorer when it is launched by watir-webdriver

internet-explorer,selenium,selenium-webdriver,watir-webdriver,developer-tools
I am automating a web application on Internet Explorer using Watir-webdriver and ruby. When I run my script in my Laptop[Win7(x64) and IE11] it is running without opening Developers Tool in Internet explorer. But When I test the same script in Virtual Machine[Win8(x64) and IE10], Intenet Exploerer browser opening with...

How to improve Sauce Labs test execution speed for watir+ruby+rspec via Jenkins? [closed]

ruby,jenkins,webdriver,watir-webdriver,saucelabs
I have a problem when I run tests on Sauce Labs using watir + ruby + rspec via Jenkins CI. The entire test suite executes very slow. How can I improve the execution speed?

Why is the execution time for present? twice as long as visible? in ruby/watir?

ruby,watir-webdriver
After reading several web pages including Testing by Justin Ko which says exists? – Returns whether this element actually exists. present? – Returns true if the element exists and is visible on the page visible? – If any parent element isn’t visible then we cannot write to the element. The...

ruby cannot load file when run from LaunchControl?

ruby,watir,watir-webdriver,launchd
I have a ruby file that runs files directly in command line via: ruby /Users/Greg/Dropbox/source_ruby/myapp/main.rb When I try to schedule this using LaunchControl on Mac however (using the same command line call) I get the following error? /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- watir-webdriver (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in...

Watir element containing embedded parentheses reporting as not visible?, not present? and not exists?

watir-webdriver
Watir is reporting that actually visible text, isn't visible if the string I'm searching for contains parentheses unless the search string starts and ends with parentheses. I am testing a non-public web page that contains (and displays) a string that looks like this Maintenance Configuration (2) database A search for...

Trying to load a yaml file, iterate through the hash and execute some logic

ruby,selenium-webdriver,watir-webdriver,page-object-gem,pageobjects
Trying to load a yaml file, iterate through the hash and execute some logic. I'm using Watir-Webdriver/Ruby to answer randomly selected questions, the questions/answers are known and stored in a YAML file (kba.yml). I'm using Ruby/Page Objects/YAML file/Watir-Webdriver. My YAML file (kba.yml): 1: question: "Which of the following is a...

How can i download with watir webdriver?

html,ruby,watir-webdriver,downloading,webautomation
Here is the code on their website but I'm not understanding what to do exactly. I'm still considerably new to Ruby. download_directory = "#{Dir.pwd}/downloads" download_directory.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows? profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.folderList'] = 2 # custom location profile['browser.download.dir'] = download_directory profile['browser.helperApps.neverAsk.saveToDisk'] = "text/csv,application/pdf" b = Watir::Browser.new :firefox, :profile => profile...

How to access the tags using watir

ruby,watir,watir-webdriver
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...

Batch file to open multiple instances of cmd and run Ruby script in each instance

ruby,windows,batch-file,cmd,watir-webdriver
I'm trying to open multiple instances of cmd up which each run a ruby script at the same time. For background into the scripts, each of these ruby scripts run watir-webdriver and spawn new browser instances. All of this should happen instantaneously. Here's what I've tried: start cmd /k cd...

How to select a combo list text item defined within in a div tag where all div tags have the same class name using watir webdriver

watir-webdriver
I am trying to select an item in a combo-list with text "1 : 272988" where the combo list is defined as a list of div tags all with the same class name as below: <div style="width: 108px; height: 300px;" id="ext-gen334" class="x- combo-list-inner"> <div class="x-combo-list-item">1 : 1066</div> <div class="x-combo-list-item">1 :...

Click button with Watir can't find button

ruby,watir,watir-webdriver
Trying to test a poll vote with Watir. Just using a script at the moment, and I can't get the script to find the correct button. HTML (reformatted slightly for readability) <a href="#" class="btn-poll-short" data-action-url="http://url.com/poll/vote.do" data-svar="svar1" data-type="picture_5569154" data-action="a:1" data-socialpollanswer="Yes" data-pollid="5569154" data-shareanswerpicture="" onclick="s_objectID=&quot;http://www.url.com/news/world-news/protective-dad-makes-daughter-wear-5568808#_3&quot;;return...

watir-webdriver --ignore-certificate-errors passed while I do not want to ignore it (Chrome)

watir-webdriver
I would like Watir to start Google Chrome without getting a message about an unsupported option '--ignore-certificate-errors'. I already tried the following too: browser = Watir::Browser.new :chrome, :switches => %w[] The basic problem I want to solve is to do a secure automated login. Note: this problem has already been...

How can I call a div class under div in watir?

ruby,webdriver,watir,watir-webdriver
I am creating automated test scripts with Ruby and Watir. I am trying to call a div class from these lines of codes: <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 500px;"> <div class="modal-body" style="overflow: hidden; width: auto; height: 500px;"> <form id="user-form" class="form-inline" enctype="multipart/form-data" method="POST" novalidate="novalidate"> <fieldset></fieldset> </form> </div>...

Ruby headless watir-webdriver Xvfb zombies

ruby,watir-webdriver,centos6,headless,xvfb
I have two apps running on a single server that perform headless browsing tasks. Each time one browses, the Xvfb process is not dying and instead becomes a zombie. I can confirm this with the following script. require 'headless' require 'watir-webdriver' require 'yaml' zombies_at_start = `ps axo pid=,stat= | awk...

How do I reconnect to an orphaned Watir browser

ruby,cucumber,watir,watir-webdriver
I'm using Ruby + Watir + Cucumber for test automation. At the start of each Feature, I launch a new browser, and at the end I generally leave the browser running for the time being (while I work through developing my scenarios). Sometimes when I'm ironing the kinks out of...

Unable to access text field in an iframe

ruby,watir-webdriver
I am trying to automate script for testing using Watir-Webdriver. While writing a script, I am at a point where I have to fill in log in details. Now would it have been in a simple text_field, I know the syntax and it would be easier. But when I inspect...

Connecting to a SQL server using watir web driver

ruby,sql-server,automation,rubygems,watir-webdriver
I need some help connecting to a SQL database held on a server to compare some values in watir webdriver. Not even sure where to start really. Is there any particular GEM i need to install My database lives on server xxx.xxx.xxx.xxx, with a username and password so I have...

Google Search Automation Script using Watir webdriver

ruby,watir-webdriver
I have to run a ruby script in watir webdriver to automate google search. Then click on first link in google search results and check if my search term exists on that page. So far I am able to reach till step where I have automated searching part but I...

How to disable download window in firefox with watir-webdriver?

firefox,selenium,watir,watir-webdriver
I don't want to handle download window in Firefox or IE. I want to auto download the excel file without any download window. I have tried to set several configuration parameters for Firefox, but it didn't work. In my test I'm trying to download excel file profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.lastDir']...

Error accessing Birthday variable using Watir during gmail sign-up

ruby,watir,watir-webdriver,firewatir
I am trying to create the gmail account through watir. As part of it while I am trying to select the birthday using div element I am unable to do. I tried with the below one: @ie.div(:text,'May').click My system configurations: IE-8 Windows-7 ...

Cannot run test execution using watir/taza/rspec

ruby,testing,rspec,watir-webdriver,qa
I'm using Unix system and trying to run Watir/Taza/RSpec test execution. I just perform commands for creating taza structure, site, homepage and flow: > taza create structure > taza site google > taza page home google > taza flow search google Then I run test using next command: rake spec:isolation:google...

Access HTML element using watir

html,ruby,watir,watir-webdriver,watir-classic
Hi I want to compose the mail,the textarea of the mail has the following HTML code Can anyone help me out how to access it using watir In have done the following steps but couldn't get it irb require 'rubygems' require 'watir' @ie.body(:id,':158').set 'text' MY system configuration is IE-8 Windows-7...

MiniTest::Unit::TestCase Functions

ruby,selenium-webdriver,watir,watir-webdriver
I am learning watir-webdriver. And I have this code: require 'watir-webdriver' require 'minitest/autorun' class Login < MiniTest::Unit::TestCase def test_in() browser =Watir::Browser.new browser.goto 'just testing' accept_next_alert=true browser.text_field(:name => 'username').set('admin') browser.text_field(:name => 'password').set('admin') browser.button(:name => 'login').click sleep 3 browser.link(:text => 'Dashboard').click browser.link(:href => '/user/').click sleep 5 browser.button(:class => 'btn btn-add').click end...

What's wrong with this code? It only run once [closed]

ruby,watir-webdriver
require 'watir-webdriver' require 'minitest/autorun' class Test2 < MiniTest::Unit::TestCase def test_2 browser =Watir::Browser.new :firefox browser.goto 'http://gw03.nextix.org/login' accept_next_alert=true browser.text_field(:name, "username").clear browser.text_field(:name, "username").send_keys "hubeunice" browser.text_field(:name, "password").clear browser.text_field(:name, "password").send_keys "test1" browser.text_field(:name, "login").click browser.text_field(:name, "password").clear browser.text_field(:name,...

Why is that return document.getElementsByClassName is working and getElementbyId is not in Watir?

javascript,ruby,watir,watir-webdriver
I have this line of codes: puts @browser.execute_script('return document.getElementsByClassName("modal-content")[0]').html it works, it display the HTML tags in my page source.. But when I try it with the other fields using this one: puts @browser.execute_script('return document.getElementById("street")[0]').innerHTML and also this line of code: puts @browser.execute_script('return document.getElementById("street")[0]').html I've got an error that says:...

Ruby incompatible character encodings

ruby,encoding,watir,watir-webdriver
I am currently trying to write a script that iterates over an input file and checks data on a website. If it finds the new data, it prints out to the terminal that it passes, if it doesn't it tells me it fails. And vice versa for deleted data. It...

Watir-Webdriver Control Android ChromeDriver on Android Device

android,selenium-webdriver,webdriver,watir-webdriver,selenium-chromedriver
I downloaded ChromeDriver https://sites.google.com/a/chromium.org/chromedriver/downloads and put it in my platform-tools folder within the Android SDK folder. I have my phone connected and it appers to be setup correcly, when I run ./chromedriver it says $ ./chromedriver Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 9515 Only local connections are allowed. However how...

Access cell in table and click

ruby,watir-webdriver
I am writing a script to automate certain tasks. I am at a point where I have a table and hyperlinked name written in its second row, first column ([2][1]). I want to access that cell and click on it to go to intended page. Structure of the page looks...

If else not working

ruby,watir,watir-webdriver
I am having trouble with this one, I try to change the conditions and add other options but still I got the same error.. can someone help me? Thanks a lot! this is my codes: require 'watir-webdriver' require 'minitest/autorun' require "win32ole" class Login < Minitest::Unit::TestCase $number_of_fails = 0 $number_of_success =...

how to display content of text file in the browser using watir?

ruby,watir,watir-webdriver
I am trying to save the results of my test in the log_file.txt and I want it to display in the browser. Is it possible? Thanks in advance, Helfe...

Cucumber: How to run the After hook only once after all examples in scenarion_outline

ruby,cucumber,watir-webdriver
I have a scenario_outline which tests login screen of a website. Scenario_outline: Try to login Verify login Examples: | User | Pass | | user1 | pass1 | | user2 | pass2 | I want to be able to start the web page at the beginning and close if after...

Select textarea by using the class and ID with Watir-WebDriver

ruby,watir-webdriver,remedy
Trying to figure out how to select a field on a form using textarea with specifying the class and the ID. Unfortunately, I don't have control over the HTML that is generated as it is a vendor product. Sample HTML: <textarea class="text sr " id="arid_WIN_0_636875000" style="left: 402px; top: 0px; width:...