1

enter image description here

Please find the above image to inspect.

I want to click not now button but it is not able find it.

I have tried below code:

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()

1 Answer 1

1

try this xpath :

//button[text()='Not Now']

and I would suggest you to have explicit wait introduce while automating insta :

wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Not Now']"))).click()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks this is working but after clicking next window button is not working which was working previously stackoverflow.com/questions/68198324/… refer this question i guess you only have answered this question.
that answer was given by hugo alejandro guerra peralta, I only formatted that answer. anyway, what is the error when you try to interact with next window button
Oops sorry my bad !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.