Prechádzať zdrojové kódy

Add documentation about parameter find subs

Daniel Gempesaw 11 rokov pred
rodič
commit
1ea917537f

+ 61 - 2
lib/Selenium/Remote/Driver.pm

@@ -1771,8 +1771,27 @@ sub get_page_source {
 =head2 find_element
 
  Description:
-    Search for an element on the page, starting from the document root. The
-    located element will be returned as a WebElement object.
+    Search for an element on the page, starting from the document
+    root. The located element will be returned as a WebElement
+    object. If the element cannot be found, we will CROAK, killing
+    your script. If you wish for a warning instead, use the
+    parameterized version of the finders:
+
+        find_element_by_class
+        find_element_by_class_name
+        find_element_by_css
+        find_element_by_id
+        find_element_by_link
+        find_element_by_link_text
+        find_element_by_name
+        find_element_by_partial_link_text
+        find_element_by_tag_name
+        find_element_by_xpath
+
+    These functions all take a single STRING argument: the locator
+    search target of the element you want. If the element is found, we
+    will receive a WebElement. Otherwise, we will return 0. Note that
+    invoking methods on 0 will of course kill your script.
 
  Input: 2 (1 optional)
     Required:
@@ -2024,6 +2043,46 @@ sub find_child_elements {
     }
 }
 
+=head2 find_element_by_class
+
+See L</find_element>.
+
+=head2 find_element_by_class_name
+
+See L</find_element>.
+
+=head2 find_element_by_css
+
+See L</find_element>.
+
+=head2 find_element_by_id
+
+See L</find_element>.
+
+=head2 find_element_by_link
+
+See L</find_element>.
+
+=head2 find_element_by_link_text
+
+See L</find_element>.
+
+=head2 find_element_by_name
+
+See L</find_element>.
+
+=head2 find_element_by_partial_link_text
+
+See L</find_element>.
+
+=head2 find_element_by_tag_name
+
+See L</find_element>.
+
+=head2 find_element_by_xpath
+
+See L</find_element>.
+
 =head2 get_active_element
 
  Description:

+ 11 - 0
lib/Selenium/Remote/Finders.pm

@@ -1,10 +1,21 @@
 package Selenium::Remote::Finders;
 
+# ABSTRACT: Handle construction of generic parameter finders
 use Try::Tiny;
 use Carp qw/carp/;
 use Moo::Role;
 use namespace::clean;
 
+=head1 DESCRIPTION
+
+This package just takes care of setting up parameter finders - that
+is, the C<find_element_by_.*> versions of the find element
+functions. You probably don't need to do anything with this package;
+instead, see L<Selenium::Remote::Driver/find_element> documentation
+for the specific finder functions.
+
+=cut
+
 sub _build_find_by {
     my ($self, $by) = @_;