Selenium Perl

Post on 02-Dec-2014

136 views 4 download

description

A presentation on beginning using Selenium Perl on the mac.

Transcript of Selenium Perl

SeleniumPerl

By Caroline Burns

Selenium

RoadmapI. What is it

2. How to set up3. How to use

4. Q & A

Selenium is a web-based automation tool,

widely used for automating tests.

It allows you to enter information, etc.

How to setup on Mac:

1. cpanm Selenium::Remote::Driver

2. cpanm -v git://github.com/gempesaw/Selenium-Remote-Driver.git@cpan

3. Download jdk, if needed

4.Download Selenium server jar file

https://www.facebook.com/WebDriver/posts/

472939509473965?stream_ref=10

5. java -jar path/to/selenium-server-standalone-2.40.0.jar

How to use

use Selenium::Remote::Driver;

my $driver = Selenium::Remote::Driver->new;

$driver->get('http://www.google.com');

print $driver->get_title();$driver->quit();

<!DOCTYPE html><html> <head> <title> This is a test. </title> </head>

<body style="background-color: rgb(255, 153, 204);">

Login: <input type="text" name="login"><br> Password: <input type="text" name="password"><br> </body></html>

use Selenium::Remote::Driver;

my $driver = Selenium::Remote::Driver->new;

$driver->get("http://carolineswebsite.us/test3.html");sleep(10);$driver->find_element("//input[\@name='login']")->send_keys('test user');$driver->find_element("//input[\@name='password']")->send_keys('password');sleep(10);$driver->quit();

~

Add to bottom:

my $elem = $driver->find_element("//input[\@id='submit']");$driver->mouse_move_to_location(element => $elem, xoffset => 0, yoffset => 0);$driver->click;sleep(10);$driver->quit();

<!DOCTYPE html><html> <head> <script type="text/javascript"> function show_msg(){

alert("Look! The message. What does it mean?"); } </script> <title> This is a test. </title> </head>

<body style="background-color: rgb(255, 153, 204);">

Login: <input type="text" name="login"><br> Password: <input type="text" name="password"><br> <input type="submit" id="submit" onclick="show_msg()" value="Submit" /> </body></html>

For more information:

https://metacpan.org/

pod/Selenium::Remot

e::Driver

Questions