Skip to content

Commit

Permalink
Update the page objects documentation to use the newer syntax for fin…
Browse files Browse the repository at this point in the history
…ding elements by name. (#113)

This follows-up the changes done in #99 (commit 3b13c2f )
  • Loading branch information
caarmen authored Nov 16, 2023
1 parent e676270 commit 9a0c8e3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/page-objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Page elements

The ``element.py`` will look like this::

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait


Expand All @@ -129,17 +130,17 @@ The ``element.py`` will look like this::

driver = obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_element_by_name(self.locator))
driver.find_element_by_name(self.locator).clear()
driver.find_element_by_name(self.locator).send_keys(value)
lambda driver: driver.find_element(By.NAME, self.locator))
driver.find_element(By.NAME, self.locator).clear()
driver.find_element(By.NAME, self.locator).send_keys(value)

def __get__(self, obj, owner):
"""Gets the text of the specified object"""

driver = obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_element_by_name(self.locator))
element = driver.find_element_by_name(self.locator)
lambda driver: driver.find_element(By.NAME, self.locator))
element = driver.find_element(By.NAME, self.locator)
return element.get_attribute("value")


Expand Down

0 comments on commit 9a0c8e3

Please sign in to comment.