I'm creating rambler autoreg mail using selenium python and encountered a problem that selenium can't find the item by xpath on the page, although it is there. It's clear from the error that selenium just can't find the item (error text at the very bottom). Been looking for a solution, but they are mostly all related to another problem, please help you, thanks in advance.
HTML
...
<footer class = "styles_popupFooter__1pUND" ...>
<div class="styles_footer__wCsAz rui-Typography-reset rui-Typography-text">
<a class="styles_link___lR7s styles_link__lCdad" ... >Registration<a>
...
<div>
...
<footer>
...
Python
# Selenium 4
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
class GenerateEmail:
def __init__(self, driver):
self.driver = driver
self.wait = WebDriverWait(driver, 30)
def main(self):
url = "https://mail.rambler.ru/?utm_source=head&utm_campaign=self_promo&utm_medium=header&utm_content=mail"
self.driver.get(url)
value = '//div[@class="styles_footer__wCsAz rui-Typography-reset rui-Typography-text"]//a[text()="Registration"]'
self.wait.until(EC.element_to_be_clickable((By.XPATH, value)))
button = self.driver.find_element(by=By.XPATH, value=value)
button.click()
def start():
try:
s = Service(executable_path='driver/geckodriver.exe')
driver = webdriver.Firefox(service=s)
g_email = GenerateEmail(driver)
g_email.main()
except Exception as e:
print(e)
finally:
driver.close()
if __name__ == '__main__':
start()
Error
Message:
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:186:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:398:5
element.find/</<@chrome://remote/content/marionette/element.js:300:16