how to click on the link using python selenium? how to click on the link using python selenium? selenium selenium

how to click on the link using python selenium?


from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.common.exceptions import TimeoutExceptionimport urllib, os, urllib.requestimport timedriver = 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()


It sounds likely that your problem can be solved by waiting explicitly for the elements to be present on the page. See section 5.1 Explicit Waits of the following documentation

http://selenium-python.readthedocs.io/waits.html

Something like this:

wait = WebDriverWait(driver, 10)element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))

Note: the explicit wait should be used after you've entered your username, password and clicked submit


Seems that "Edit Profile" is just an option for "Profile" drop-down menu, so it's not visible initialy. You should click on "Profile" first to open drop-down menu. Try:

driver.find_element_by_link_text("Profile").click()driver.find_element_by_link_text("Edit Profile").click()

UPDATE

Using XPath:

driver.find_element_by_xpath('//a[@class="nav-link"][contains(text(),"Profile")]').click()driver.find_element_by_xpath('//a[@href="/profile/edit?trk=nav_responsive_sub_nav_edit_profile"]').click()