Find and click an item by name Python Selenium

I am looking for a site. In the check item, see This:

<span id="item60" title="Havai 30" class="item button link">Get</span> <span id="item90" title="Classic 50" class="item button link">Get</span> 

You need to get and click an item by name. Something like that:

 browser.find_element_by_xpath('//*[@id="item60"]').click() 

But through the headline.

+5
source share
4 answers

Like Barak manos, the answer was as follows:

 '//*[@title="Havai 30"]' 

With the ending [0], if it was a list.

+9
source

browser.find_element_by_xpath('//*[@title="Havai 30"]').click()

This will work for me, as you said.

+2
source

For me it works with Object Object Pattern:

 @FindBy(xpath = "//*[@title='Havai 30']") WebElement imHavai; 
0
source

For java, if someone was looking for an answer here, like me:

 String title="SOME TITLE"; driver.findElement(By.cssSelector("[title^='"+title+"']")).click(); 
0
source

Source: https://habr.com/ru/post/1200590/


All Articles