I have figured out how to find a subelement of an element using Selenium in python using this Stack overflow post.
Selenium Get WebElement inside a WebElement
I want to take it one step further. I want to be able to perform actions on the subelement. Going off the previous example:
<div class='wrapper'>
<div class='insider1'>
<div class='insider2'>
<div class='wrapper'>
<div class='insider1'>
<div class='insider2'>
I am trying to do something like
elements = driver.find_elements_by_xpath('//div')
for element in elements:
sub_element = element.find_element_by_xpath('//div')
if sub_element.is_displayed()
ActionChains(driver) \
.move_to_element(sub_element ) \
.click(sub_element ) \
.perform()
Yes, I could just do sub_element.click() in this example but I want to do more types of interactions.
The example as is cannot find the element subelement. And if I put ActionChains(element) instead of ActionChains(driver), the code throws an error because element is a webElement and not a webDriver.