0

I am trying to automate login in LinkedIn with Python and Selenium.

Where I am stuck so far is on the Sign in button. When I try to click it with

driver.find_element_by_xpath('//a[text()="Sign in"]').click() I get an error:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (1273, 80). Other element would receive the click: ... (Session info: chrome=79.0.3945.130)

Tried also driver.find_element_by_xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "nav__button-secondary", " " ))]').click() which I generate by using SelectorGadget extension for Google Chrome and got the same error as mentioned above...

As for my Chrome version it is : Version 79.0.3945.130 (Official Build) (64-bit) same as my WebDriver version for Windows.

mastaofthepasta
  • 91
  • 1
  • 2
  • 9

2 Answers2

0

It looks like when you open linkedin, the page is scrolled down a little bit. Try scrolling up to the top or more precise - scrolling to the element

You could also just copy the link that 'sign in' button points to and go there straight away.

If signing in is not the whole point, you can also sign in manually and tell selenium to use your profile, so you're already signed in when the script starts.

Exporting cookies might also do the trick.

EDIT: closing the pop-up window solved it.

RafalS
  • 5,834
  • 1
  • 20
  • 25
  • It's not the scrolling, it's the `Sign in` window with the fields that hides the other `Sign in` button that screws the things. When I close that window it works fine. Somehow there must be a way to close it, before trying to click the button. – mastaofthepasta Feb 01 '20 at 14:30
  • I don't see it ;/. Why don't you just use right click > inspect element. And right click on html tag you want to click > copy > xpath? And close it? Also why going straight to https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin is not an option? – RafalS Feb 01 '20 at 14:35
  • `driver.find_element_by_class_name('sign-in-card__dismiss-btn').click()` Closing the extra Sign in window that was hiding the button did the work. Edit your answer sir, you helped me debugging it. – mastaofthepasta Feb 01 '20 at 14:39
0

I automated the login using Python 3 and Selenium 3.141.0 today (I don't know how long it will work) and I found a way to do it using find_element_by_class_name with the sign-in-form__submit-button class name:

def run(email, password):
#Open Chrome web
driver = webdriver.Chrome()
driver.get('https://www.linkedin.com/')

#Login username/password
email_box = driver.find_element_by_id('session_key')
email_box.send_keys(email)
pass_box = driver.find_element_by_id('session_password')
pass_box.send_keys(password)
submit_button = driver.find_element_by_class_name('sign-in-form__submit-button')
submit_button.click()

I'm using Chrome Version 88.0.4324.96 (Official Build) (x86_64) on MacOS.

GuiFalourd
  • 15,523
  • 8
  • 44
  • 71