Im using firefox on ubuntu 22.04 (Codename: jammy) (I installed it with apt and not snap). My Selenium Version is (4.2.0) and I'm using python3.
My code:
#!/bin/usr/python3
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
#driver = webdriver.PhantomJS()
driver.get('https://euw.leagueoflegends.com/en-gb/')
time.sleep(5)
driver.refresh()
#search_field = driver.find_element_by_id('truste-show-consent')
#search_field = driver.find_element("id", "login")
#ID = "id"
#search_field = driver.find_element(By.ID, "login")
search_field = driver.find_element(By.ID,'truste-show-consent')
#driver.find_element("id", "login")
print(search_field.text)
driver.send_keys(Keys.F5)
search_field.click()
I'm getting the following error message:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5
element.find/</<@chrome://remote/content/marionette/element.js:291:16
CodePudding user response:
To be honest, I accessed this page on my Firefox driver and I could not find any id="truste-show-consent" so maybe that's the problem.
If you need to login with credentials or something first and then the specific id appears, you have to do the same actions with selenium.