c# selenium chrome-webdriver write advanced Path (chrome-driver)

亡梦爱人 提交于 2019-12-08 12:35:28

问题


I just try to write correct path to click exactly this button what I want on my page. I will give you an example page for testing. You just have to download the HTML file and open it in your browser.Code of HTML page What we now want to do? If you run this HTML file you will see all page. And now we want to make a Click on exactly this button on screen : After when you click on this button you will see click counter below: like this :

Have anyone idea how to click it? I tried few ways and can't find solution still. Please help. I try at least :

drive.FindElement(By.XPath("//tr[class='ng-scope']/td[text()='Wylaczenie nadan RDF'] and button[@title='Skip']")).Click();

and

drive.FindElement(By.XPath("//tr[text()='Wylaczenie nadan RDF']/button[@title='Skip']")).Click();

+ more and more and can't just write fine this Path to click exacly this button. And unique value is <td class="ng-binding">Wylaczenie nadan RDF</td> - i prefer to get path by this.


回答1:


You need to use below XPATH for the same

//tr[td='Wylaczenie nadan RDF']//button[@title='Skip']"

//tr[td='Wylaczenie nadan RDF'] will take you to the row which contains that text and then you use //button[@title='Skip'] to find that button



来源:https://stackoverflow.com/questions/46611317/c-sharp-selenium-chrome-webdriver-write-advanced-path-chrome-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!