Reputation: 11
So I have seen many answers on this type of error and have implemented implicit wait to give time for the button to load. I have checked and it doesn't seem to be in an iframe. Further-more when I run the same code through the interactive console it actually works. Here is my code:
from selenium import webdriver
from time import sleep
class TinderBot():
def __init__(self):
self.driver = webdriver.Chrome()
def login(self):
self.driver.get('https://tinder.com')
self.driver.implicitly_wait(3)
fb_btn = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div/div/main/div/div[2]/div[2]/div/div/span/div[2]/button')
fb_btn.click()
bot = TinderBot()
bot.login()
Upvotes: 0
Views: 115
Reputation: 11
So I got it working the problem was when i went to inspect the page, because of my small screen the html and therefor the xpath of the button would change. So when the code went to find it it was not there.
Upvotes: 1
Reputation: 74
i believe the problem is with the xpath rather than implicitly_wait() try to give a generic xpath something like this '//*[@id="content"]//button'
def login(self):
self.driver.get('https://tinder.com')
self.driver.implicitly_wait(3)
fb_btn = self.driver.find_element_by_xpath('//*[@id="content"]//button')
fb_btn.click()
Upvotes: 0