EzDevInfo.com

watir-classic

Watir is a Ruby browser-driver suitable for apps in any language. Watir.com | Web Application Testing in Ruby watir, pronounced water, is an open-source (bsd) family of ruby libraries for automating web browsers. it allows you to write tests that are easy to read and maintain. it is simple and flexible. watir drives browsers the same way people do. it clicks links, fills in forms, presses buttons. watir also checks results, such as…

How to retrieve process ID for IE browser instance using Ruby or WATIR?

IE Browser instance is open. How do I get the process id for the Browser instance or opened tab for the browser using WATIR or Ruby:

require "Watir"
browser = Watir::Browser.new
browser.goto "www.google.com"
puts Watir::Browser::Process.process_id_from_hwnd browser.hwnd

Source: (StackOverflow)

File uploading working manually but not through program

My upload of csv file goes in this way, there is a text box where file path can be loaded through the browser button subsequently I would press the upload button, Now my problem reside here, While I try to do the aforementioned process through manually it's workign fine, but what happens is, when I try to do through programmetically, It's clearing the text field at the time of clicking the upload button consequently empty is taken from text field while uploading, so it's not uploading anything.

My piece of code :

$browser.file_field(:id,"additionalInfo(clientUri)").click_no_wait
      sleep 2
      save_dialog = WIN32OLE.new("AutoItX3.Control")
      save_dialog.ControlSend("Choose File to Upload", "", "Edit1", sMEPackageData['MachineryUploadPath'])
      sleep 2
      saveClick=save_dialog.ControlClick("Choose File to Upload","", "&Open")
      sleep 2

ruby 1.8.7,watir 3.0.0 Can anyone please help me on this ?


Source: (StackOverflow)

Advertisements

How to execute two or more executions scripts simultaneously on a same URL using WATIR

I am using watir 2.0.1,currently if a script is running on url say ABC.com in one tab for IE browser and if i opens same url ABC.com in other tab or new instance of the browser then the execution will switch to this new tab open. Because of this i am not able to execute multiple scripts/executions on same URL

Here is the code for Script1.rb in Project1,

require 'watir'
browser = Watir::Browser.new
browser.goto 'https://example.com'
browser = Watir::Browser.attach(:title, /ABC Application/)
browser.button(:text,"Register").click
sleep 2
browser.text_field(:id,"First_Name").set "Script_1_FirstName"
sleep 2
browser.text_field(:id,"Last_Name").set "Script_1_LastName"

and so on...

While Script1 is filling the register form for ABC application in Browser instance1,at the same time(Say after Script1 Enters First Name, i will trigger Script2.rb for some basic validations of the register form page.

Here is the code for Script2.rb in Project2,

require 'watir'
browser1 = Watir::Browser.new
browser1.goto 'https://example.com'
browser1 = Watir::Browser.attach(:title, /ABC Application/)

//At this time Script2 will execute properly in IE Instance2 as there is
//no Register button at IE instance1(Because Script1 is already on
//Register form page) 

browser1.button(:text,"Register").click

//The movement Register form opens in IE instance2,Script1 finds same page
//elements on IE instance2 so currently Script1 is automatically start its
//execution on IE instance2 which will affect Script2 Execution.     

if(browser1.text_field(:id,"First_Name").text.include("")
puts "First name field is blank by default"
else
raise "First name field is not blank by default"

if(browser1.text_field(:id,"Last_Name").text.include("")
puts "Last name field is blank by default"
else
raise "Last name field is not blank by default"

Source: (StackOverflow)

Access HTML element using watir

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

    <div class="Ar Au" id=":88" style="display: block;">
    <iframe tabIndex="1" class="Am Al editable" id=":83" src="html/compose/static_files/blank_quirks.html" frameBorder="0" style="padding-bottom: 0px; background-color: white; padding-left: 0px; padding-right: 0px; height: 245px; overflow: visible; padding-top: 0px;" allowTransparency="allowtransparency" closure_lm_423419="null">
<body class="editable LW-avf" id=":158" role="textbox" contentEditable="true"
    hideFocus="hidefocus" closure_lm_478727="[object Object]" g_editable="true"/>

Source: (StackOverflow)

Two files are found in WATIR-Classic 3.0.0 but not in WATIR-Classic 3.7.0

I can find two files named 'testcase.rb' and 'assertions.rb' in WATIR-CLASSIC 3.0.0, but those two files are not found in WATIR-CLASSIC 3.7.0. What is the reason for this? Or is it found in some other folder?


Source: (StackOverflow)