c#selenium chrome-webdriver编写高级路径(chrome-driver) [英] c# selenium chrome-webdriver write advanced Path (chrome-driver)

查看:1279
本文介绍了c#selenium chrome-webdriver编写高级路径(chrome-driver)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是尝试编写正确的路径,在我的页面上点击我想要的按钮。我会给你一个测试页面。您只需下载HTML文件并在浏览器中打开它。
当你点击这个按钮后,你会看到点击计数器如下:像这样:



有没有人知道如何点击它?我尝试了几种方法,仍然找不到解决方案。请帮忙。
我至少尝试:

pre $ drive.FindElement(By.XPath(// tr [class ='ng -scope'] / td [text()='Wylaczenie nadan RDF']和按钮[@ title ='Skip']))。Click();

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

+越来越多,不能直接写这个Path来点击这个按钮。
并且唯一的值是< td class =ng-binding> Wylaczenie nadan RDF< / td> - 我更喜欢通过它获得路径。 / p>

解决方案

您需要在XPATH下使用相同的

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

// tr [td ='Wylaczenie nadan RDF'] 会带您到包含该文本的行,然后使用 //按钮[@ title ='跳过'] 找到该按钮


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.

解决方案

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

这篇关于c#selenium chrome-webdriver编写高级路径(chrome-driver)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆