找不到按钮,selenium.common.exceptions.NoSuchElementException
not able to find button , selenium.common.exceptions.NoSuchElementException
请找到上图查看
我想单击“现在不”按钮,但无法找到它。
我试过下面的代码:
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Not Now']"))).click()
notification1 = driver.find_element_by_xpath("//*[contains(@class,'pV7Qt')]")
offbt = notification1.find_element_by_xpath(".//*[@class='ABCxa']//*[@class='cmbtv']//*[@class='sqdOP yWX7d "
"y3zKF ']")
offbt.click()
wait = WebDriverWait(driver, 10)
notification = driver.find_element_by_xpath("//*[contains(@class,'pbNvD')]")
offbt1 = notification.find_element_by_xpath(".//*[@class='piCib']//*[@class='mt3GC']//*[@class='aOOlW HoLwm ']")
offbt1.click()
试试这个 xpath :
//button[text()='Not Now']
我建议您在自动化 insta 时明确引入 wait :
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Not Now']"))).click()
进口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
请找到上图查看
我想单击“现在不”按钮,但无法找到它。
我试过下面的代码:
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Not Now']"))).click()
notification1 = driver.find_element_by_xpath("//*[contains(@class,'pV7Qt')]")
offbt = notification1.find_element_by_xpath(".//*[@class='ABCxa']//*[@class='cmbtv']//*[@class='sqdOP yWX7d "
"y3zKF ']")
offbt.click()
wait = WebDriverWait(driver, 10)
notification = driver.find_element_by_xpath("//*[contains(@class,'pbNvD')]")
offbt1 = notification.find_element_by_xpath(".//*[@class='piCib']//*[@class='mt3GC']//*[@class='aOOlW HoLwm ']")
offbt1.click()
试试这个 xpath :
//button[text()='Not Now']
我建议您在自动化 insta 时明确引入 wait :
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Not Now']"))).click()
进口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC