From 5141f672ae0a3d7115b646e294f1f1c5888c48c5 Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Thu, 16 Jan 2025 15:00:39 -0500 Subject: [PATCH 1/2] [py] Added Docstrings to By Class --- py/selenium/webdriver/common/by.py | 54 +++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/py/selenium/webdriver/common/by.py b/py/selenium/webdriver/common/by.py index 65a74649f070e..fb22db81d2093 100644 --- a/py/selenium/webdriver/common/by.py +++ b/py/selenium/webdriver/common/by.py @@ -22,7 +22,59 @@ class By: - """Set of supported locator strategies.""" + """Set of supported locator strategies. + + ID: + -- + Select the element by its ID. + + >>> element = driver.find_element(By.ID, 'myElement') + + XPATH: + ------ + Select the element via XPATH. + - absolute path + - relative path + + >>> element = driver.find_element(By.XPATH, '//html/body/div') + + LINK_TEXT: + ---------- + Select the link element having the exact text. + + >>> element = driver.find_element(By.LINK_TEXT, 'myLink') + + PARTIAL_LINK_TEXT: + ------------------ + Select the link element having the partial text. + + >>> element = driver.find_element(By.PARTIAL_LINK_TEXT, 'my') + + NAME: + ---- + Select the element by its name attribute. + + >>> element = driver.find_element(By.NAME, 'myElement') + + TAG_NAME: + -------- + Select the element by its tag name. + + >>> element = driver.find_element(By.TAG_NAME, 'div') + + CLASS_NAME: + ---------- + Select the element by its class name. + + >>> element = driver.find_element(By.CLASS_NAME, 'myElement') + + CSS_SELECTOR: + ------------- + Select the element by its CSS selector. + + >>> element = driver.find_element(By.CSS_SELECTOR, 'div.myElement') + + """ ID = "id" XPATH = "xpath" From 824ef4a792465df83926a43fbf9690aa55f8e370 Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Thu, 16 Jan 2025 15:02:43 -0500 Subject: [PATCH 2/2] format.sh --- py/selenium/webdriver/common/by.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py/selenium/webdriver/common/by.py b/py/selenium/webdriver/common/by.py index fb22db81d2093..cf4a3a220eb46 100644 --- a/py/selenium/webdriver/common/by.py +++ b/py/selenium/webdriver/common/by.py @@ -23,7 +23,7 @@ class By: """Set of supported locator strategies. - + ID: -- Select the element by its ID. @@ -32,7 +32,7 @@ class By: XPATH: ------ - Select the element via XPATH. + Select the element via XPATH. - absolute path - relative path @@ -73,7 +73,6 @@ class By: Select the element by its CSS selector. >>> element = driver.find_element(By.CSS_SELECTOR, 'div.myElement') - """ ID = "id"