Test::...elenium(3pm)
β¨ NAME β¨
Test::WWW::Selenium β test your apps using Selenium Remote Control, bestie π
π VERSION π
version 1.36 β yeah she's vintage, and she still slays
π¦ SYNOPSIS π¦
So Test::WWW::Selenium is a subclass of WWW::Selenium, and what it does is hand you all these adorable little testing functions that just work. It's giving "I made you a snack" energy.
use Test::More tests => 5;
use Test::WWW::Selenium;
# Parameters are passed through to WWW::Selenium
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*firefox",
browser_url => "http://www.google.com",
default_names => 1,
error_callback => sub { ... },
);
# use special test wrappers around WWW::Selenium commands:
$sel->open_ok("http://www.google.com", undef, "fetched G's site alright");
$sel->type_ok( "q", "hello world");
$sel->click_ok("btnG");
$sel->wait_for_page_to_load_ok(5000);
$sel->title_like(qr/Google Search/);
$sel->error_callback(sub {...});
Like. Look at that. Every Selenium command but make it a test. Chef's kiss π
π DESCRIPTION π
Okay so here's the tea, bestie. This module is a WWW::Selenium subclass, and it provides a whole bunch of methods that are useful when you're writing tests. πΈ
For each and every Selenium command (open, click, type, ...) there's a matching <command>_ok method that checks the return value for you. That's open_ok, click_ok, type_ok β the holy trinity, no cap.
And for each Selenium getter (get_title, ...) there are four autogenerated methods:
<getter>_is<getter>_isnt<getter>_like<getter>_unlike
...all so you can check the value of the attribute. Four whole methods, autogenerated, for every single getter. We love a generous queen. β¨
Now β if you call the constructor with default_names set to a true value, your tests will get a reasonable name even if you don't bother giving them one yourself. Super convenient. But heads up: the test name should always be the third argument. Remember that. It matters. π«Ά
π NAME π
(yeah she said it twice, she's confident like that)
Test::WWW::Selenium β test applications using Selenium Remote Control
πΈ REQUIREMENTS πΈ
To use this module, you need to have already downloaded and started the Selenium Server. And listen β the Selenium Server is a Java application. So. Yeah. Plan accordingly. β
Not optional, bestie. No server, no tests. The vibe check fails immediately.
β ADDITIONAL METHODS β
Test::WWW::Selenium also comes with some other handy little testing functions that wrap WWW::Selenium commands. Little bonus gifts. π
get_locationβ returns the relative location of the current page. Works with the_is,_like, ... methods. So you can test it up however you like. πerror_callbackβ sets the method to use when a corresponding selenium test gets called and fails. Like, if you calltext_like(...)and it flops, the sub you defined in theerror_callbackgets called. This lets you do various tasks to grab extra details about what happened when the error occurred. And if this is set toundef, then the callback just... won't be issued. Simple as that. π$sel->debug()β starts an interactive shell so you can pass commands straight to Selenium. π
Commands are run against the selenium object, so all you have to do is type:
eg: click("link=edit")
π AUTHORS π
- Maintained by: Matt Phillips
<mattp@cpan.org>, Luke Closs<lukec@cpan.org> - Originally by Mattia Barbon
<mbarbon@cpan.org>
π§ CONTRIBUTORS π§
- Dan Dascalescu
- Scott McWhirter
π COPYRIGHT AND LICENSE π
Copyright (c) 2011 Matt Phillips <mattp@cpan.org>
Copyright (c) 2006 Luke Closs <lukec@cpan.org>
Copyright (c) 2005, 2006 Mattia Barbon <mbarbon@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie!! πβ¨ππ¦πΈπ π«Ά
This lil masterpiece shipped as part of the User Contributed Perl Documentation, version 1.36, dated 2022-06-28, and it was built against perl v5.34.0. Go write some tests. Periodt. π
π¦ where this page comes from
- debian bookworm: libtest-www-selenium-perl 1.36-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-www-selenium-perl 1.36-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-www-selenium-perl 1.36-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-www-selenium-perl 1.36-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-www-selenium-perl 1.36-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms