Reputation: 41
I am trying to use selenium on this site(https://www.kijiji.ca/t-login.html)
here is the code I use
driver=webdriver.Chrome(PATH)
driver.get("https://www.kijiji.ca/t-login.html")
driver.find_element_by_id("emailOrNickname")
but I keep getting
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="emailOrNickname"]"}
Upvotes: 1
Views: 157
Reputation: 978
please use following xpath to click and sendkeys to email field
driver=webdriver.Chrome(PATH)
driver.get("https://www.kijiji.ca/t-login.html")
driver.find_element_by_xpath("//input[@id="emailOrNickname"]");
Upvotes: 0
Reputation: 382
There's nothing wrong with your code. If you look at the response headers from the site you will see
server: rhino-core-shield
This is an indication that the server could be protected by a web application firewall.
If you inspect what you're actually getting back from the website using
driver.page_source
you will see that you're not actually getting the login page you expected, instead you are getting a horrible pile of Javascript which will presumably redirect to the real login page. The upshot is that this particular website's login page is going to be quite difficult to access programatically.
Upvotes: 1
Reputation: 665
I think this website detects selenium. Because I can reach the site with normal browser but selenium does not show anything at login or register page. You need to bypass it if possible.
Upvotes: 1
Reputation: 1920
Try
from bs4 import BeautifulSoup
soup = BeautifulSoup(driver.page_source, 'html.parser')
soup.find_all('input', {'id': 'emailOrNickname'})`
Upvotes: 1