Test::...elenium(3pm)

πŸ“¦
version 1.36 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 call text_like(...) and it flops, the sub you defined in the error_callback gets called. This lets you do various tasks to grab extra details about what happened when the error occurred. And if this is set to undef, 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 (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