I am using selenium webdriver wherein I want to get list of all the text present in the table i am able to extract names of all table present in it however i want to extract the names only till specific person i.e "C. Kelly" however my code is extracting all the names below is the code
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path="C:/chromedriver")
driver.get("https://www.seleniumeasy.com/test/")
driver.maximize_window()
time.sleep(5)
driver.find_element_by_xpath("//a[text()='No, thanks!']").click()
driver.find_element_by_xpath("//a[contains(text(),'Table')]").click()
driver.find_element_by_xpath("//a[contains(text(),'Table Sort & Search')]").click()
time.sleep(10)
FullName = driver.find_elements_by_xpath("//td[@class='sorting_1']")
time.sleep(10)
for Names in FullName:
if Names == "C. kelly":
break
Names1 = Names.text
print(Names1)
You are comparing a webelement with a string in line if Names == "C. kelly"
.
You can use if Names.text == "C. kelly"
.
Also the name in website is C. Kelly not C. kelly