Issue
I use Python Scrapy and i try to connect to this site.
I create a test account for this question
Email: [email protected]
password: 123456789
When I monitor the network during authentification
I tried to fill the form with FormRequest
data = {'loginName': '[email protected]',
'password' : '123456789',
'rememberme' : 'true'
}
yield FormRequest("https://ecustomermw.colruytgroup.com/ecustomermw/v1/fr/customer/logon?client=cogo_cogo&variant=none" ,method="POST",formdata=data)
but I'm not logged in and I redirected to signup page
I read this answer and I tried with Selenium
username = driver.find_element_by_id("loginName")
password = driver.find_element_by_id("password")
username.send_keys("[email protected]")
password.send_keys("123456789")
driver.find_elements_by_class_name("button.btn.large").click()
But I'm not logged in and I redirected to signup page
Where am I wrong?
Solution
Your Selenium code is almost correct. The problem is that authentication form located inside an iframe and you should switch to it to be able to handle inputs:
driver.switch_to.frame(driver.find_element_by_css_selector('iframe._loadEvent'))
driver.find_element_by_id('loginName').send_keys('[email protected]')
driver.find_element_by_id('password').send_keys('123456789')
driver.find_element_by_css_selector('button[type="submit"]').click()
Answered By - Andersson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.