0

I run the following code and it works till the last button clicking and I get this error:

selenium.common.exceptions.NoSuchElementException: 
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="joinGame"]/a/button/span"}
(Session info: chrome=80.0.3987.132)

Code:

from selenium import webdriver
import time

first = 'https://lobby.ogame.gameforge.com/pl_PL/hub'
browser = webdriver.Chrome('my chromedriver directory')
browser.get(str(first))
browser.maximize_window()
l = browser.find_element_by_xpath('//*[@id="loginRegisterTabs"]/ul/li[1]/span')
l.click()
c = browser.find_element_by_name('email')
c.send_keys('myemail')
p = browser.find_element_by_name('password')
p.send_keys('mypassword')
o = browser.find_element_by_xpath('//*[@id="loginForm"]/p/button[1]/span')
o.click()
b = browser.find_element_by_xpath('//*[@id="joinGame"]/a/button/span')
b.click()

The b command causes the error.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Kuba
  • 5
  • 6
  • You can wait for the element before clicking on it. See https://stackoverflow.com/questions/56380889/wait-for-element-to-be-clickable-using-python-and-selenium –  Mar 16 '20 at 19:28
  • 1
    Does this answer your question? [Selenium "selenium.common.exceptions.NoSuchElementException" when using Chrome](https://stackoverflow.com/questions/47993443/selenium-selenium-common-exceptions-nosuchelementexception-when-using-chrome) – Svetlana Levinsohn Mar 16 '20 at 19:36
  • Unfortunately it doesnt change anything:( I think it just doesnt see the element. – Kuba Mar 16 '20 at 20:03
  • Can I have this question reopened because the solutions in the similar questions do not work for me. The program works fine but it cant find the path to the other button in function b. Can it be caused by the https adress changing ? If so, how do I read the next https ? – Kuba Mar 16 '20 at 20:37

0 Answers0