Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to click on the link using python selenium?

I am trying to log in into my linkedin using python selenium. I am able to open my homepage but after that I want to open the following link present on my homepage

<a href="/profile/edit?trk=nav_responsive_sub_nav_edit_profile">
Edit Profile
</a>

I used the following code which allows me to open my homepage-

import getpass
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.support.ui import WebDriverWait
url = "https://www.linkedin.com/uas/login"
driver = webdriver.Firefox()
driver.get(url)
username = 'email-id'
password = 'password'
user = driver.find_element_by_name("session_key")
for j in username:
    user.send_keys(j)
pasw = driver.find_element_by_name("session_password")
for j in password:
    pasw.send_keys(j)
driver.find_element_by_css_selector("div.form-buttons>input").click()
driver.find_element_by_link_text("Edit Profile").click()

but i get the following error message-

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"link text","selector":"Edit Profile"}

like image 686
cgkentrus Avatar asked May 28 '16 05:05

cgkentrus


1 Answers

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import urllib, os, urllib.request
import time

driver = webdriver.Safari()

usrName = 'your_email'
pssWrd = "your_password"

driver.maximize_window()
driver.get("https://www.linkedin.com/uas/login?")

driver.find_element_by_name('session_key').send_keys(usrName)
driver.find_element_by_class_name('password').send_keys(pssWrd)
driver.find_element_by_name('signin').click()
like image 51
Chris Brocious Avatar answered Oct 27 '22 18:10

Chris Brocious