How to find element in selenium python using both id and class in div and then click it:
<div id="abc" class="xyz" style="" role="presentation"></div>
I am using the following code:
arrow = driver.find_element_by_xpath('//div[@id="abc"][@class="xyz"]')
arrow.click()
But I am getting error as:
NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//div[@id=\"abc\"][@class=\"xyz\"]"}
Use below:-
arrow = driver.find_element_by_xpath('//div[@id="abc" and @class="xyz"]')
arrow.click()
Here in XPath "and" operator is being used to combine id and class together
Hope it will help you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With