Skip to content

Commit

Permalink
added feature to other languages
Browse files Browse the repository at this point in the history
  • Loading branch information
shbenzer committed Aug 19, 2024
1 parent 5fe24f3 commit 01f0372
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,24 @@ from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.example.com")

##get elements from parent element using TAG_NAME

# Get element with tag name 'div'
element = driver.find_element(By.TAG_NAME, 'div')

# Get all the elements available with tag name 'p'
# NOTE: in order to utilize XPATH from current element, you must add "." to beginning of path
elements = element.find_elements(By.TAG_NAME, 'p')
for e in elements:
print(e.text)

##get elements from parent element using XPATH

# Get first element of tag 'ul'
element = driver.find_element(By.XPATH, '//ul')

# get children of tag 'ul' with tag 'li'
elements = driver.find_elements(By.XPATH, './/li')
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,24 @@ from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.example.com")

##get elements from parent element using TAG_NAME

# Get element with tag name 'div'
element = driver.find_element(By.TAG_NAME, 'div')

# Get all the elements available with tag name 'p'
# NOTE: in order to utilize XPATH from current element, you must add "." to beginning of path
elements = element.find_elements(By.TAG_NAME, 'p')
for e in elements:
print(e.text)

##get elements from parent element using XPATH

# Get first element of tag 'ul'
element = driver.find_element(By.XPATH, '//ul')

# get children of tag 'ul' with tag 'li'
elements = driver.find_elements(By.XPATH, './/li')
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down

0 comments on commit 01f0372

Please sign in to comment.