abcdef abcdef - 3 months ago 14
HTML Question

scrapping content using selenium not working

I am willing to login to this website using selenium. So I have imported the web driver and for sending the login information to that page I have also imported the Keys.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


This I used to prepare the selenium,

chromedriver = "chromedriver.exe"
browser = webdriver.Chrome(chromedriver)
browser.get("https://m.adidas.com/us/myaccount-create-or-login")


I have made the browser to wait until the page loads using "implicitly wait function"

The user name column in the website has HTML content like this,



<input type="text" value="" placeholder="* EMAIL" data-placeholder="* Email" maxlength="50" class="textinput required trimspace" name="username" id="username">





And for password it has



<input type="password" placeholder="* PASSWORD" data-placeholder="* Password" maxlength="50" autocomplete="off" name="password" value="" class="textinputpw required" id="password">





I have found the id's of the two elements with the above code and then I wrote this code to send the personal info

username1 = browser.find_element_by_id("username")
password1 = browser.find_element_by_id("password")
username1.send_keys(email.get()) # Used a gui entry box so why email.get()
password1.send_keys(password.get())


But the above code is not sending the info I don't know why it is? Could you help me with this please?

I have tried sending the keys using x path also. Printed the page source to check the website produces 403 Access denied error but that is not in my case.

I am new to this kindly bare if anything is wrong

EDIT :- My Try:

username1 = browser.find_element_by_id("username")
browser.switch_to.frame(username1)
password1 = browser.find_element_by_id("password")
browser.switch_to.frame(password1)
username1.send_keys(email.get()) # Used a gui entry box so why email.get()
password1.send_keys(password.get())

Answer

The elements you are trying to reach are inside an IFRAME.

<iframe id="loginaccountframe" class="sso-iframe" src="https://cp.adidas.com/web/eCom/en_US/loadsignin?target=account" frameborder="0" scrolling="no"></iframe>

You will need to switch into the IFRAME before you can see them.

http://selenium-python.readthedocs.io/navigating.html#moving-between-windows-and-frames