How To Select An Element Based On A Polyline Using Selenium And Python?
I am trying to select and click on an element in Selenium, but it doesn't have the typical tags, and the xpath changes on reload. The symbol stays consistent though, and I want to
Solution 1:
As you are able to grab the element by the data-handle
attribute, so you don't have to reach till the <polyline>
tag. Instead, to click on the element you have to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
Using
CSS_SELECTOR
:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[title='Close sharing menu'][aria-label='Close sharing menu'] > div[data-handle='shareButton']"))).click()
Using
XPATH
:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@title='Close sharing menu' and @aria-label='Close sharing menu']/div[@data-handle='shareButton']"))).click()
Note: You have to add the following imports :
from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.common.byimportByfrom selenium.webdriver.supportimport expected_conditions asEC
Post a Comment for "How To Select An Element Based On A Polyline Using Selenium And Python?"