Question on watir

I am automating Idit application using Ruby, at one screen I can’t feed
the input to one of the text box using the code
$browser.select_field(:id,"").set() what could be the reason.?

Raj

I think it’s usually select_list, and you haven’t entered an id to look
for. You also haven’t given a value to set to.

hi thanks for reply.
I just place the syntax, My original line is this
“$browser.text_field(:id,‘IDITForm@pmlPercentage’).set(23)”

it gives the error

“Unable to locate element, using {:tag_name=>[“text”, “password”,
“textarea”], :id=>“IDITForm@pmlPercentage”}”

But I can manually enter the value into this text box. while I am
writing this line “puts
$browser.text_field(:id,‘IDITForm@pmlPercentage’).exists?” it prints
false. But that element is present there.

If so, what would be the solution?

Raj

There are a few reasons it might not work.

Try navigating to the page using a Watir browser running through
Interactive Ruby so you can do some live experimentation.

Try using longer paths, like specifying any parent elements (frames in
particular):
thisfield =
$browser.frame(:index,0).text_field(:id,‘IDITForm@pmlPercentage’)

Ensure that the page is fully loaded before looking for the field, In
order to do this, I use Watir-Webdriver rather than just Watir alone, so
I tend to use when_present:
$browser.text_field(:id,‘IDITForm@pmlPercentage’).when_present.set(23)

Otherwise, try locating all (or some of) the text fields and iterating
through them to make sure you have the details exactly right (name, id,
value, etc.):
$browser.text_fields.each {|el| puts el.id }

No problem, I struggled to find documentation when starting out with
Watir, but it’s getting better all the time.

These are handy resources:

http://watirwebdriver.com/

http://www.rubydoc.info/github/jarib/watir-webdriver/

Hi,

Really so much thank you for your reply, Actually I have already solved
the problem, I solved the problem by executing via IRB mode in dos mode,
But confusion still reamins because I was not able to identified what
that problem was. But after i went through the IRB mode,scripts is also
working fine, i haven’t done any changes in scripts. . And some of your
codings(give below) are useful for me for further work. Thank you so
much for you reply.

“$browser.text_field(:id,‘IDITForm@pmlPercentage’).when_present.set(23)”
“$browser.text_fields.each {|el| puts el.id }”

Thanks,
Raj

Hi Joel P.

Thank you so much.

RAJ

Hi Joel P.

I am using eclipse for automation,when i am executing the program using
debug mode,Once i executed some lines, is it possible to bring the
control back to some lines before, and continue execution from there or
debugging from there?What i meant to ask was, can i bring back the
control after execution happens,and then continue the execution from
there on(from new place)?

Raj

Hi Joel P.

please look at this error,

[15:51:13] [ERROR] : Error attaching: excelOpen: false , fileOpen:
false, file:
C:\work1\IDITTestAutomationProject\TestData\TestData_MyCopy.xls error:
Open
OLE error code:800A03EC in Microsoft Office Excel
‘TestData_MyCopy.xls’ cannot be accessed. The file may be
corrupted, located on a server that is not responding, or read-only.
HRESULT error code:0x80020009
Exception occurred.
Open
OLE error code:800A03EC in Microsoft Office Excel
‘TestData_MyCopy.xls’ cannot be accessed. The file may be
corrupted, located on a server that is not responding, or read-only.
HRESULT error code:0x80020009
Exception occurred.

I encounter this error so often, I haven’t opened any Excel file during
execution, But still i am encountering this error, what is the reason ?
But if I close the eclipse and open again then this won’t be coming.How
to solve this error without closing the eclipse?

Raj

Raj pal wrote in post #1084536:

Hi Joel P.

please look at this error,

[15:51:13] [ERROR] : Error attaching: excelOpen: false , fileOpen:
false, file:
C:\work1\IDITTestAutomationProject\TestData\TestData_MyCopy.xls error:
Open
OLE error code:800A03EC in Microsoft Office Excel
‘TestData_MyCopy.xls’ cannot be accessed. The file may be
corrupted, located on a server that is not responding, or read-only.
HRESULT error code:0x80020009
Exception occurred.
Open
OLE error code:800A03EC in Microsoft Office Excel
‘TestData_MyCopy.xls’ cannot be accessed. The file may be
corrupted, located on a server that is not responding, or read-only.
HRESULT error code:0x80020009
Exception occurred.

I encounter this error so often, I haven’t opened any Excel file during
execution, But still i am encountering this error, what is the reason ?
But if I close the eclipse and open again then this won’t be coming.How
to solve this error without closing the eclipse?

Raj

You may have crashed out without closing the process which is accessing
the file. In that case, you might have an invisible process locking the
file which is being terminated when you close Eclipse.
Have a look at this for example:


begin
excel = WIN32OLE::new(“excel.application”)
#Do some stuff where excel might crash
rescue
excel.Quit()unless excel.nil?
end


Within that code, if you experience an error inside the begin/end block,
excel will close and therefore stop locking whichever file it’s
accessing. You should probably do the same type of exception-based
garbage collection with any object which might lock files.

Hi,

I got it, Thank you.

Raj

i don’t understand, what do you mean by “unsubscribe”?

Raj

unsubscribe

Hi Raj,

People seem to have gotten the idea that they unsubscribe by sending the
word “unsubscribe” to the list itself.

Unfortunately, this is mistaken; it’ll no sooner unsubscribe them than
would shouting unsubscribe at the computer screen.

If they really want to unsubscribe, they can either use the form here:

http://www.ruby-lang.org/en/community/mailing-lists/

Or they can mail the word “unsubscribe” to the list controller
address, which for ruby-talk is:

[email protected]

Cheers,

Arlen

Hi Arlen

Thank you , I was confused when i saw the word unsubscribe,because i
thought somebody was asking me to unsubscribe. Now it’s clear .

Raj

hi Joel P.

I have a question, For an example consider that I have to execute 10
test case, but at the first attempt it is found that internet has been
down, in such situation, it is not terminating the execution, but it
tries to run the remaining test cases, any idea to stop this as soon as
it realizes internet connection has been down.? It should not execute
the remaining test cases as soon as it is found internet connection has
been down.

Raj

Yeah I will start a new thread if i have question in future, Thank you
so much.

Raj

hi,

I couldn’t create a new thread, If press submit button, it came back to
the preview window .So I am posting here.

I have installed Ruby 1.8.7 and while i was trying to install “gem
install watir” it gives the error "ERROR: Error installing
watir:win32-process requires Ruby version > 1.9.0."But it was not the
case when i installed the Ruby last time? Is there any way to install
win32-process in version 1.8.7?Or is there any way can i able to install
“gem install watir” without any error?

Raj

You’d need to install a version compatible with 1.8.7:
“gem install watir -v (version number here)”
But a far better approach is to upgrade to Ruby 1.9.3.

“gem install watir -v (version number here)”

I used this “gem install watir -v 3.0.0” (the reason I have used is,I
have watir 3.0.0 for Ruby 1.8.7 in my computer already)Now i am
installing into another system. But anyway i couldn’t succeed with
installation using the above syntax.

Raj