| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- #!perl
- use Test::More;
- use Selenium::Remote::MockCommands;
- use Selenium::Remote::MockRemoteConnection;
- use Test::Selenium::Remote::Driver;
- use Test::Selenium::Remote::WebElement;
- # Start off by faking a bunch of Selenium::Remote::WebElement calls succeeding
- my $mock_commands = Selenium::Remote::MockCommands->new;
- my $spec = { };
- foreach my $k (
- qw/clearElement clickElement submitElement sendKeysToElement isElementSelected isElementEnabled isElementDisplayed/
- ) {
- $spec->{$k} = sub { return { status => 'OK', return => 1 }};
- }
- $spec->{getElementTagName} = sub { return { status => 'OK', return => 'iframe' }};
- $spec->{getElementValue} = sub { return { status => 'OK', return => 'my_value' }};
- $spec->{getElementText} = sub { return { status => 'OK', return => "my_text\nis fantastic" }};
- $spec->{getElementAttribute} = sub { my $name = $_[1]; return { status => 'OK', return => "my_$name" }};
- my $driver =
- Test::Selenium::Remote::Driver->new(
- remote_conn => Selenium::Remote::MockRemoteConnection->new( spec => $spec, mock_cmds => $mock_commands ),
- commands => $mock_commands,
- );
- my $successful_element = Test::Selenium::Remote::WebElement->new(driver => $driver);
- $successful_element->clear_ok;
- $successful_element->click_ok;
- $successful_element->submit_ok;
- $successful_element->is_selected_ok;
- $successful_element->is_enabled_ok;
- $successful_element->is_displayed_ok;
- $successful_element->send_keys_ok('Hello World');
- $successful_element->tag_name_is( 'iframe', 'we got an iframe tag' );
- $successful_element->tag_name_isnt( 'BOOM', 'tag name is not boom' );
- $successful_element->tag_name_unlike( qr/BOOM/, "tag_name doesn't match BOOM" );
- # check_test(
- # sub {
- # $successful_element->tag_name_unlike( qr/BOOM/,
- # "tag_name doesn't match BOOM" );
- # },
- # { ok => 1,
- # name => "tag_name doesn't match BOOM",
- # diag => "",
- # }
- # );
- # }
- # # value_*
- # {
- # check_test(
- # sub {
- # $successful_element->value_is( 'my_value',
- # 'Got an my_value value?' );
- # },
- # { ok => 1,
- # name => "Got an my_value value?",
- # diag => "",
- # }
- # );
- # check_test(
- # sub { $successful_element->value_isnt( 'BOOM', 'Not BOOM.' ) },
- # { ok => 1,
- # name => "Not BOOM.",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->value_like( qr/val/,
- # 'Matches my_value value?' );
- # },
- # { ok => 1,
- # name => "Matches my_value value?",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->value_unlike( qr/BOOM/,
- # "value doesn't match BOOM" );
- # },
- # { ok => 1,
- # name => "value doesn't match BOOM",
- # diag => "",
- # }
- # );
- # }
- # # text_*
- # {
- # check_test(
- # sub {
- # $successful_element->text_is( "my_text\nis fantastic",
- # 'Got an my_text value?' );
- # },
- # { ok => 1,
- # name => "Got an my_text value?",
- # diag => "",
- # }
- # );
- # check_test(
- # sub { $successful_element->text_isnt( 'BOOM', 'Not BOOM.' ) },
- # { ok => 1,
- # name => "Not BOOM.",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->text_like( qr/tex/,
- # 'Matches my_text value?' );
- # },
- # { ok => 1,
- # name => "Matches my_text value?",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->text_unlike( qr/BOOM/,
- # "text doesn't match BOOM" );
- # },
- # { ok => 1,
- # name => "text doesn't match BOOM",
- # diag => "",
- # }
- # );
- # }
- # {
- # check_test(
- # sub {
- # $successful_element->attribute_is( 'foo', 'my_foo',
- # 'attribute_is matched' );
- # },
- # { ok => 1,
- # name => "attribute_is matched",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->attribute_isnt( 'foo', 'not_foo',
- # 'attribute_is not_foo' );
- # },
- # { ok => 1,
- # name => "attribute_is not_foo",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->attribute_like( 'foo',qr/foo/,
- # 'Matches my_attribute' );
- # },
- # { ok => 1,
- # name => "Matches my_attribute",
- # diag => "",
- # }
- # );
- # check_test(
- # sub {
- # $successful_element->attribute_unlike( 'bar',qr/foo/,
- # "Attribute does not match foo" );
- # },
- # { ok => 1,
- # name => "Attribute does not match foo",
- # diag => "",
- # }
- # );
- # }
- # css_attribute_is($attr_name,$match_str,$test_name);
- # css_attribute_isnt($attr_name,$match_str,$test_name);
- # css_attribute_like($attr_name,$match_re,$test_name);
- # css_attribute_unlike($attr_name,$match_re,$test_name);
- done_testing();
|