0

This code used to work:

time.sleep(3)

driver.switch_to.window(window_facebook)

driver.find_element_by_xpath("//input[@name=\"email\"]").send_keys(fb_email)
driver.find_element_by_xpath("//input[@name=\"pass\"]").send_keys(fb_pass)
driver.find_element_by_xpath("//input[@name=\"login\"]").click()

driver.switch_to.window(window_tinder)

time.sleep(3)

driver.find_element_by_xpath("//span[contains(text(), 'Allow')]").click()
#driver.find_element_by_xpath("//span[contains(text(), 'ALLOW')]").click()
#driver.find_element_by_xpath("//button[@aria-label=\"Allow\"]").click()

time.sleep(3)

driver.find_element_by_xpath("//span[contains(text(), 'Not interested')]").click()

This used to work, but now it stopped working with the following error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[contains(text(), 'Allow')]"}
driver.find_element_by_xpath("//span[contains(text(), 'Allow')]").click()

Screenshots:

Sariq Shaikh
  • 940
  • 8
  • 29
Dennis
  • 2,866
  • 7
  • 32
  • 49
  • Hard coded sleep time is not a good practice to use. Did you tried to wait until the element is visible on the screen ? In your screenshot its visible but just to make sure. – Sariq Shaikh Mar 22 '20 at 11:07
  • if it was working previously then why dont you try to add WebDriverWait before performing click action. it could be possible server is taking time to load the page – SeleniumUser Mar 22 '20 at 11:07

1 Answers1

0

As per my comment above server might taking time to load your page. Try below code and check if its working for you.

Imports required

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as Wait

Code with WebDriverWait

element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(), 'Allow')]")))
element.click()
SeleniumUser
  • 4,065
  • 2
  • 7
  • 30