Reputation: 23
Website
myList = ['Artik']
How can I check if content of myList is visible in website above?
<span class="ipo-TeamStack_TeamWrapper">Artik<span>
This is the webelement holding 'Artik' in the website.
My goal is to click the element containing 'Artik' and do some stuff after that.
Upvotes: 1
Views: 377
Reputation: 366
This is how you find an element by xpath in selenium. I am using Firefox here but you can use Chrome as well.
from selenium import webdriver
myList = ['Artik']
driver = webdriver.Firefox() # or .Chrome()
driver.get('www.theWebsite.com')
current = driver.find_element_by_xpath('//span[@class="ipo-TeamStack_TeamWrapper"]').text
if current in myList:
print('YAY')
driver.quit()
Upvotes: 1
Reputation: 185
driver.find_elements_by_xpath("//*[contains(text(), 'Artik')]")
this return WebElement list contain 'Artik'.
parameter(like 'Artik') is case sensitive.
if you are convinced 'Artik' is only one,
driver.find_element_by_xpath("//*[contains(text(), 'Artik')]").click()
this will find WebElement with 'Artik' and click.
Upvotes: 0