Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在这段代码下面创建xpath_Html_Selenium_Xpath_Webdriver - Fatal编程技术网

Html 如何在这段代码下面创建xpath

Html 如何在这段代码下面创建xpath,html,selenium,xpath,webdriver,Html,Selenium,Xpath,Webdriver,我正在尝试创建xpath这个非计划访客签入按钮。我找不到按钮名称或id。有人能帮我解决这个问题吗。我会很感激的。请看附件 <div id="SAFEControl307369" class="buttontextactivestyle" uniquefieldid="307369" onselectstart="return false" onchange="setAttribute('IsModified','1');" onclick=" document.body.style.cur

我正在尝试创建xpath这个非计划访客签入按钮。我找不到按钮名称或id。有人能帮我解决这个问题吗。我会很感激的。请看附件

<div id="SAFEControl307369" class="buttontextactivestyle" uniquefieldid="307369" onselectstart="return false" onchange="setAttribute('IsModified','1');" onclick=" document.body.style.cursor = 'wait'; window.location.href = 'QSForm.aspx?FormID=194&Hidden=1';return false;" datatype="" boundcolumn="" ismodified="0" style="position:absolute;left:280px;top:5px;height:0px;width:250px; ;" caption="" tabindex="-1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr style="height:20px;cursor:pointer;">
<td class="buttonleftactivestyle"/>
<td class="buttonmiddleactivestyle" align="center">
<div>Unscheduled Visitor Check-In</div>
[Screenshot of the application with xpath][1]

请使用以下xpath:

//div[contains(.,'Unscheduled Visitor Check-In')]
您可以尝试以下代码:

WebElement element= driver.findElement(By.xpath("Your XPath"));

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
请随意更改上面代码中的定位器。请尝试使用firepath提供的xpath,如图所示

IWebElement element = driver.FindElement(By.XPath("//div[@id='SAFEControl307369']/table/tbody/div"));

检查元素时,您需要查看创建XPath的尝试。

您尝试了什么,结果如何?就像你在学校做的那样。。。请出示你的作品这是获得问题答案的过程的一部分。它对你很有帮助,因为它迫使你调查自己的问题并仔细思考。它还向读者证明,你做了功课,并做出了合理的尝试来回答自己的问题。第三,它帮助读者找到并诊断问题,从而为您提供更好的答案,减少我们的时间浪费。感谢您的帮助,但很抱歉此代码不起作用欢迎Satyajit。。如果答案真的对你有用,你能接受吗对不起,兄弟,我打错了,我被回复了,它现在起作用了。我的回复可能不起作用,我对此深表歉意。