使用C#用于XPATH的目标是什么?
目标:当我单击按钮时,它应该转到我想要的站点,然后在文本框中输入文本=“ test”(id =“ 1648750690212editingInput”)。
我能够用Chrome中的硒扩展来完成它,但是目标是XPATH:iDrelative,看起来像xpath = // table [@id ='gridlist_headers']]/thead/thead/tr [2]/td [2 ]/div/div [2]/跨度/输入。
问题:如何格式化C#中的XPATH来实现这一目标?
html < input type =“ text” class =“ ui-igedit输入ui-igedit-placephorder ui-iggrid-filterereditor” label =“ text Editor”样式=“高度:100%; text-align:left;”>
c#
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://fakesite.com");
driver.FindElement(By.XPath("//table[@id='gridList_headers']/thead/tr[2]/td[2]/div/div[2]/span/input")).SendKeys("test");
}```
GOAL: when I click the button, it should go to the site I want and enter text = "test" in a textbox (id="1648750690212EditingInput").
I am able to accomplish it with the selenium extension in chrome but the target the works is xpath:idRelative and it looks like this xpath=//table[@id='gridList_headers']/thead/tr[2]/td[2]/div/div[2]/span/input.
QUESTION: How do I format the xpath in C# to accomplish this?
HTML<input type="text" class="ui-igedit-input ui-igedit-placeholder ui-iggrid-filtereditor" id="1648750690212EditingInput" placeholder="Contains..." role="textbox" aria-label="Text Editor" style="height: 100%; text-align: left;">
C#
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://fakesite.com");
driver.FindElement(By.XPath("//table[@id='gridList_headers']/thead/tr[2]/td[2]/div/div[2]/span/input")).SendKeys("test");
}```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常输入字段使用发布请求
因此,您可以将文本带有get request并将其发布回到服务器中的
简单请求请求
简单的
帖子请求,正如您在XPATH上所要求的,您可以将其与Regex一起使用,它将为您提供在HTML文件上的强大搜索
usually input fields use post requests
so you can get the text with Get request and post back values to the server
Simple GET request
Simple POST request
and as you asked on xpath you can use it with regex and it will give you a powerfull searching on html files