Can Watir support PHP based technology?

368 views
Skip to first unread message

Ashu

unread,
Feb 24, 2011, 1:56:22 AM2/24/11
to Watir General
Hi,
As the fact is that php-based has no bearing on the way watir
interacts with it, because php is all done
server-side and watir only deals with the html that is delivered to
the browser.
I would like to know
is there any way wherein a PHPs functionality be wrapped thereby
letting Watir to use the PHP page HTML elements?
Or any other alternative wherin watir dealing with the html can be
delivered to the browser.
Thanks :-)

Željko Filipin

unread,
Feb 24, 2011, 3:58:06 AM2/24/11
to watir-...@googlegroups.com
On Thu, Feb 24, 2011 at 7:56 AM, Ashu <ashay...@gmail.com> wrote:
> is there any way wherein a PHPs functionality be wrapped thereby
> letting Watir to use the PHP page HTML elements?

"An example would be handy right about now" Brian Marick would say.

If you are asking if Watir can automate PHP web applications, answer is yes.

Željko
--
watir.com - community manager
watirpodcast.com - host
testingpodcast.com - audio podcasts on software testing. all of them

Ashu

unread,
Feb 24, 2011, 7:45:28 AM2/24/11
to Watir General
I am dealing with automation of the PHP web page.
It repeatedly gives the error Unable to locate the element
as compared to if the page is saved (web page complete)
i.e.webpage.php.html.
There are various fieldsets on the webpage, so before these fieldsets
the class, id elements gets traced but beyond it none is being traced.
Please Help..


On Feb 24, 1:58 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:

Željko Filipin

unread,
Feb 24, 2011, 7:47:14 AM2/24/11
to watir-...@googlegroups.com
On Thu, Feb 24, 2011 at 1:45 PM, Ashu <ashay...@gmail.com> wrote:
> It repeatedly gives the error Unable to locate the element

Do you know how to use Firebug (or similar tool)?

I will say this again: "An example would be handy right about now" Brian Marick would say.

Željko

Ashu

unread,
Feb 24, 2011, 7:49:37 AM2/24/11
to Watir General
Yes,
I have Firebud installed on Firefox
and I am using it for dealing with elements(HTML automation)
Its working fine for me with HTML page


On Feb 24, 5:47 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:

Željko Filipin

unread,
Feb 24, 2011, 8:24:03 AM2/24/11
to watir-...@googlegroups.com
On Thu, Feb 24, 2011 at 1:49 PM, Ashu <ashay...@gmail.com> wrote:
> Its working fine for me with HTML page

But there is a problem inspecting the page of your PHP app?

Željko

Chuck van der Linden

unread,
Feb 24, 2011, 7:50:19 PM2/24/11
to Watir General
Like Z I think I'm perplexed here as to exactly what it is you are
wanting to do.

If the problem is elements not found on the page, and it works
'manually' from an IRB prompt, but not when you run the script, you
might need to insert a few sleep statements here and there in your
code to allow for client side code on the page to render things.
That' common with pages with lots of javascript or sometimes heavy CSS
formatting.

Unfortunately unless your page code specifically provides some way to
know when it is busy manipulating stuff, vs when it is done, there is
really no way for Watir to when the clientside operations are done.

An example of what I mean by that is what the site I'm testing does,
it has a little animated 'loading' graphic it displays when its doing
things like updating the page via jquery, or running any client side
scripts. This 'icon' resides in a div, and the system sets it visible
while clent side code is running, and then hides it again once it's
done. It's there for the users really, so they will know something is
going on, but that doesn't mean I can't use it also. So what I'm able
to do in my automation is have a method I call that looks like this

def sleepWhileLoading
while browser.div(:id, 'masterprogress').visible?
sleep 1
end
end

in my scripts, anyplace that i might need to wait for the jquery stuff
to update the page, or any other client side scripting to finish, I
just call that method.

If that's not your problem then.. 'An example would be handy right
about now'

On Feb 24, 5:24 am, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:

Ashu

unread,
Feb 27, 2011, 11:44:16 PM2/27/11
to Watir General
Yes,
as the script is running on the IP address, so a webpage opens that is
in PHP.

Watir can detect the text that is written in td[2]
xpath - /html/body/div/div/div[5]/div/div[7]/table/tbody/tr/td[2]
But,
There is an image file in the input below
/html/body/div/div/div[6]/div/fieldset/table[2]/tbody/tr[3]/td[8]/
input
as
<input type="image" halign="right" valign="middle" title="Open SDP
file" alt="Open SDP file" src="main.php_files/play-icon-big.png"
name="SDP_0_0">

So on clicking on that image file an event occurs.
But it needs to be automated.
Please Help.
Thanks!
On Feb 24, 6:24 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:

Chuck van der Linden

unread,
Feb 28, 2011, 1:46:22 PM2/28/11
to Watir General
On Feb 27, 8:44 pm, Ashu <ashay.n...@gmail.com> wrote:
> Yes,
> as the script is running on the IP address, so a webpage opens that is
> in PHP.
>
> Watir can detect the text that is written in td[2]
> xpath - /html/body/div/div/div[5]/div/div[7]/table/tbody/tr/td[2]
> But,
> There is an image file in the input below
> /html/body/div/div/div[6]/div/fieldset/table[2]/tbody/tr[3]/td[8]/
> input
> as
> <input type="image" halign="right" valign="middle" title="Open SDP
> file" alt="Open SDP file" src="main.php_files/play-icon-big.png"
> name="SDP_0_0">
>
> So on clicking on that image file an event occurs.
> But it needs to be automated.
> Please Help.
> Thanks!

What have you tried so far? what if any results did you get?

you realize it's not our job to write your code for you?

Super Kevy

unread,
Mar 1, 2011, 2:06:25 PM3/1/11
to Watir General
First I'm glad you figured out whether php, java, ruby, asp it all
plays in a browser as HTML.
That should make your life easier. At some point go through the simple
tutorials at http://www.w3schools.com/

Try this code fragment. Your trying to click an image button within a
form

require 'rubygems'
require 'watir'

sURL='http://your_test_url.htm' # Change this to your URL
browser = Watir::Browser.new
browser.goto(sURL)
sleep 3
# The input button has a name attribute so we can use it as a handle
browser.button(:name,'SDP_0_0').flash() # MAKE ME FLASH a Yellow
highlight
sleep 3
browser.button(:name,'SDP_0_0').click # The actual click of the
button
puts 'DONE'
> you realize it's not our job to write your code for you?- Hide quoted text -
>
> - Show quoted text -

Ashu

unread,
Mar 2, 2011, 3:08:47 AM3/2/11
to Watir General
Thanks alot...
It was a very helpful reply from respected Super Key
Looking at the time bound nature of the project, the above reply which
actually worked out for me will be helpful in progressing ahead with
the project.
Thanks alot.
I did observe that there are minor things that go overlooked which do
cost us lot of time consumption.


On Mar 2, 12:06 am, Super Kevy <kpe...@scholarshipamerica.org> wrote:
> First I'm glad you figured out whether php, java, ruby, asp it all
> plays in a browser as HTML.
> That should make your life easier. At some point go through the simple
> tutorials athttp://www.w3schools.com/

Super Kevy

unread,
Mar 3, 2011, 9:46:31 AM3/3/11
to Watir General
excellent:
To speed up your learning process look at the
1. api doc link: http://wtr.rubyforge.org/rdoc/1.6.5/
2. Bretts cheat sheet: http://pettichord.com/watirtutorial/docs/watir_cheat_sheet/WTR/Cheat%20Sheet.html
3. Watir home examples http://watir.com/examples/
4. Watir home docs http://watir.com/documentation/
http://wiki.openqa.org/display/WTR/Tutorial

I find newbies with any basic skill at programming can pick WATIR up
and be quite productive in a less then 2 weeks
> > > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages