1

Set-up

Trying to log into this log-in form using Python and Selenium.


Code

url = 'https://activeshop.com.pl/customer/account/login/'
browser.get(url)


# fill out login details 
account_name = 'my@email.com' 
password = 'mypassword' 

login_details = {
                'login': account_name,
                'password': password
                }

# inserts account name in login field      
fill_field('id','email',login_details['login'])      

# inserts password in password field
fill_field('id','pass',login_details['password'])   

where,

def fill_field(type, type_path, input):
    if type == 'id':
        field = browser.find_element_by_id(type_path)        
    field.clear()
    field.send_keys(input)

Issue

The above code used to work, but since the site has received a makeover it yields a ElementNotInteractableException: element not interactable when trying to fill the fields.

I've tried Xpaths, CSS selectors and whatnot, but the email address and password aren't filled out.

I can obtain texts on the page via Selenium.

There's something blocking Selenium at the input elements. Any ideas?

Guy
  • 46,488
  • 10
  • 44
  • 88
LucSpan
  • 1,831
  • 6
  • 31
  • 66

2 Answers2

3

There're more than 1 email on the page and first one is not visible. You can get all elements and then filter for visible one:

field = list(filter(lambda x: x.is_displayed(), browser.find_elements(By.ID, "email")))[0]
field.send_keys("email")
Sers
  • 12,047
  • 2
  • 12
  • 31
1

To send a character sequence to the E-mail and Hasło field you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following Locator Strategy:

  • Using XPATH:

    driver.get("https://activeshop.com.pl/customer/account/login/")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='E-mail']//following::input[@class='input-text' and @id='email']"))).send_keys("my@email.com")
    driver.find_element_by_xpath("//span[text()='Hasło']//following::input[@class='input-text' and @title='Hasło']").send_keys("mypassword")
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

activeshop_com

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352