0

I use Python Scrapy and i try to connect to this site.

I create a test account for this question

Email: g2387744@nwytg.com
password: 123456789

When I monitor the network during authentification enter image description here

I tried to fill the form with FormRequest

   data = {'loginName': 'g2387744@nwytg.com',
        '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("g2387744@nwytg.com")
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?

parik
  • 2,313
  • 12
  • 39
  • 67

1 Answers1

2

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('g2387744@nwytg.com')
driver.find_element_by_id('password').send_keys('123456789')
driver.find_element_by_css_selector('button[type="submit"]').click()
Andersson
  • 51,635
  • 17
  • 77
  • 129