Quellcode durchsuchen

Add code, docs and tests to Teset::...WebElement for text_* methods

    text_is
    text_isnt
    text_like
    text_unlike
Mark Stosberg vor 12 Jahren
Ursprung
Commit
95b4e11dbd
2 geänderte Dateien mit 46 neuen und 0 gelöschten Zeilen
  1. 6 0
      lib/Test/Selenium/Remote/WebElement.pm
  2. 40 0
      t/Test-Selenium-Remote-WebElement.t

+ 6 - 0
lib/Test/Selenium/Remote/WebElement.pm

@@ -30,6 +30,7 @@ sub one_arg {
 our %no_arg = map { $_ => 1 } qw(
     clear
     click
+    get_text
     get_value
     get_tag_name
     is_enabled
@@ -162,6 +163,11 @@ distribution, and some interfaces may change.
 All methods from L<Selenium::Remote::WebElement> are available through this
 module, as well as the following test-specific methods. All test names are optional.
 
+  text_is($match_str,$test_name);
+  text_isnt($match_str,$test_name);
+  text_like($match_re,$test_name);
+  text_unlike($match_re,$test_name);
+
   tag_name_is($match_str,$test_name);
   tag_name_isnt($match_str,$test_name);
   tag_name_like($match_re,$test_name);

+ 40 - 0
t/Test-Selenium-Remote-WebElement.t

@@ -21,6 +21,7 @@ $successful_element->set_true(qw/
 
 $successful_element->set_list('get_tag_name','iframe');
 $successful_element->set_list('get_value','my_value');
+$successful_element->set_list('get_text','my_text');
 
 # Given input 'foo' to 'get_attribute', return 'my_foo';
 $successful_element->mock('get_attribute',sub { 'my_'.$_[1] } );
@@ -174,6 +175,45 @@ check_test(
     );
 }
 
+# text_*
+{
+    check_test(
+      sub { $successful_element->text_is('my_text','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 => "",
+      }
+    );
+}
+
 #  attribute_is($attr_name,$match_str,$test_name);
 #  attribute_isnt($attr_name,$match_str,$test_name);
 #  attribute_like($attr_name,$match_re,$test_name);