I am using Python & Selenium to automate the sending request to add new connections in linkedin. Currently, I have the following problem:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//ul[contains(@class, 'reusable-search__entity-results-list list-style-none')]"} (Session info: chrome=97.0.4692.99)
Here is the element
< ul class="reusable-search__entity-result-list list-style-none">
Following is the script
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver = webdriver.Chrome(executable_path="E:\Softwares\chromedriver\chromedriver.exe") driver.get('https://www.linkedin.com/') print(driver.title) print(driver.current_url) #Login ID /Email Id user = driver.find_element_by_xpath('//*[@id="session_key"]').click() driver.execute_script("document.getElementById('session_key').value='LinkediN-Email'") #password driver.find_element_by_xpath('//*[@id="session_password"]').click() driver.execute_script("document.getElementById('session_password').value='LinkedPassword'") #signin button click driver.find_element_by_xpath('//*[@id="main-content"]/section[1]/div/div/form/button').click() #destination URL driver.get('https://www.linkedin.com/search/results/people/?origin=CLUSTER_EXPANSION&sid=bl!') time.sleep(1) print(driver.title) print(driver.current_url) time.sleep(1) #Error in SkillSelection find element by XPath unable to find the class skillsSection = driver.find_element_by_xpath("//ul[contains(@class, 'reusable-search__entity-results-list list-style-none')]") print(skillsSection) #working code iterating through list and printing elements for li in skillsSection.find_elements_by_tag_name("li"): #print(li.text) Connect_btn_contents = driver.find_elements_by_class_name('artdeco-button__text') the_one_you_want = [x for x in Connect_btn_contents if "Connect" == x.text][0] the_one_you_want.click() time.sleep(4) Send_btn = driver.find_element_by_xpath("//span[text()='Send']") print(Send_btn) Send_btn.click() driver.close()
What can be the Issue and the correct solution of the issue?