Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Selenium content

  • server_is_running}
  • body_text_contains}
  • content_contains}
  • get_text}
use strict;
use warnings;
use 5.010;

use Test::More;
use Test::Selenium::Remote::Driver;
use Selenium::Remote::WDKeys qw(KEYS);

if (not Test::Selenium::Remote::Driver->server_is_running()) {
    plan skip_all => 'The Selenium server must be running for this test';
}

plan tests => 1;

my $url = 'http://localhost:8080/'; 
my $driver = Test::Selenium::Remote::Driver->new;

subtest plain => sub {
    plan tests => 4;
    $driver->get_ok($url);
    $driver->title_is('Hello world', 'title');

    $driver->body_text_contains('Our languages');
    $driver->content_contains('<h1>Our languages</h1>');

};

  • body_text_contains - disregard HTML element
  • content_contains - check in the raw HTML
  • find_element will throw exception if cannot find element
  • find_element_ok of the test module can only use the default locator

content_* methods

  • $s->content_like($regex [,$desc])
  • $s->content_unlike($regex [,$desc])
  • $s->content_contains( $str [, $desc ] )
  • $s->content_lacks( $str [, $desc ] )

body_text_*

  • $s->body_text_like( $regex [, $desc ] )
  • $s->body_text_unlike( $regex [, $desc ] )
  • $s->body_text_contains( $str [, $desc ] )
  • $s->body_text_lacks( $str [, $desc ] )