我无法使用 Selenium 单击此按钮
I am not able to click this button using Selenium
我一直在尝试单击下面突出显示的元素:
我已经尝试了我所知道的一切。以下是我尝试过的一些代码:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/root/mat-sidenav-container/mat-sidenav-content/div/div/workspace-view/fluent-workspace/mat-sidenav-container/mat-sidenav-content/fluent-workspace-list/fluent-list-table-base/div/cdk-virtual-scroll-viewport/div[1]/div[1]/div[2]/span/button[1]/mat-icon"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CLASS_NAME, "quick-action-button ng-star-inserted"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "Refresh Now"))).click()
还有很多,但我似乎无法点击该元素。值得注意的一件事是,将鼠标悬停在屏幕上时,按钮会变得很明显。
悬停前
悬停后
如有任何帮助,我们将不胜感激。
像下面这样使用action方法点击它
from selenium.webdriver.common.action_chains import ActionChains
ele = driver.find_element_by_xpath("xpath")
actions = ActionChains(driver)
actions.move_to_element(ele).click().perform()
确保定位器正确
element_to_hover_over = driver.find_element_by_xpath("xpath")
hover = ActionChains(driver).move_to_element(element_to_hover_over)
hover.perform()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "xpath"))).click()
我一直在尝试单击下面突出显示的元素:
我已经尝试了我所知道的一切。以下是我尝试过的一些代码:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/root/mat-sidenav-container/mat-sidenav-content/div/div/workspace-view/fluent-workspace/mat-sidenav-container/mat-sidenav-content/fluent-workspace-list/fluent-list-table-base/div/cdk-virtual-scroll-viewport/div[1]/div[1]/div[2]/span/button[1]/mat-icon"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CLASS_NAME, "quick-action-button ng-star-inserted"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "Refresh Now"))).click()
还有很多,但我似乎无法点击该元素。值得注意的一件事是,将鼠标悬停在屏幕上时,按钮会变得很明显。
悬停前
悬停后
如有任何帮助,我们将不胜感激。
像下面这样使用action方法点击它
from selenium.webdriver.common.action_chains import ActionChains
ele = driver.find_element_by_xpath("xpath")
actions = ActionChains(driver)
actions.move_to_element(ele).click().perform()
确保定位器正确
element_to_hover_over = driver.find_element_by_xpath("xpath")
hover = ActionChains(driver).move_to_element(element_to_hover_over)
hover.perform()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "xpath"))).click()