Reputation: 11
I'm starting to programe in Python but i have a little problem. I want to click in this part. But when i run the program , it results that has a problem.
for driver.find_elements_by_xpath(//span[@class='link-indicator'][contains(text(),'View IP Detail')])
.click()
I write this code but my program doesn't run
Somebody can help me please.
Upvotes: 1
Views: 289
Reputation: 193088
To click on the element with text as View IP Detail you can use either of the following Locator Strategies:
Using xpath
and the textContext:
driver.find_element_by_xpath("//span[@class='link-indicator'][contains(.,'View IP Detail')]").click()
Using xpath
and the textContext of preceding element:
driver.find_element_by_xpath("//span[contains(.,'ISP')]//following::span[@class='link-indicator'][contains(.,'View IP Detail')]").click()
Ideally, to click on the element you need to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
Using XPATH
and the textContext:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='link-indicator'][contains(.,'View IP Detail')]"))).click()
Using XPATH
and the textContext of preceding element:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(.,'ISP')]//following::span[@class='link-indicator'][contains(.,'View IP Detail')]"))).click()
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Upvotes: 2