我在使用不同的定位器定位WebElement
时遇到问题。在下面的html标记中,我尝试使用不同的定位符(例如WebElement
,linkText
,xpath
)定位“撰写评论” classname
,但仍然得到NoSuchElementException
-> url https://www.tripadvisor.in/
-> search for Club Mahindra
-> click on Club Mahindra
-> click on write a review
。
<a href="/UserReview-g641714-d1156207-Club_Mahindra_Madikeri_Coorg-
Madikeri_Kodagu_Coorg_Karnataka.html" target="_blank" class="ui_button
primary">Write a review</a>
使用的定位器
By.xpath("//*[@id="component_12"]/div/div[2]/div/div[2]/div/div[1]/a")
By.xpath("//a[@href='/UserReview-g641714-d1156207-
Club_Mahindra_Madikeri_Coorg-Madikeri_Kodagu_Coorg_Karnataka.html']")
By.className("ui_button primary")
By.linkText("Write a review")
我真的很困惑。我在做什么错?
//a[contains(text(),'Write a review')]