Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.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
如何查找显示为<;的工具提示文本消息;Strong>&书信电报;br>;java中的标记_Java_Selenium_Xpath_Tooltip_Webdriverwait - Fatal编程技术网

如何查找显示为<;的工具提示文本消息;Strong>&书信电报;br>;java中的标记

如何查找显示为<;的工具提示文本消息;Strong>&书信电报;br>;java中的标记,java,selenium,xpath,tooltip,webdriverwait,Java,Selenium,Xpath,Tooltip,Webdriverwait,它给了我null值 HTML: 电子邮件地址 * 不幸的是,您提供的信息并不多。您可以使用By.TagName(“Strong)并使用By.TagName(“br”)对其进行过滤。根据您的DOM,您只需在特定的中搜索,例如,就可以大大改善这一点。尝试使用innerText <label id="jform_email-lbl" for="jform_email" class="hasTooltip required" title="" data-original-title="<s

它给了我
null

HTML:


电子邮件地址
*

不幸的是,您提供的信息并不多。您可以使用
By.TagName(“Strong)
并使用
By.TagName(“br”)
对其进行过滤。根据您的DOM,您只需在特定的
中搜索,例如,就可以大大改善这一点。

尝试使用innerText

<label id="jform_email-lbl" for="jform_email" class="hasTooltip required" title="" data-original-title="<strong>Email Address</strong><br />Please enter the email address associated with your User account.<br />A verification code will be sent to you. Once you have received the verification code, you will be able to choose a new password for your account."> 
    Email Address
    <span class="star">&nbsp;*</span>
</label>
要提取工具提示文本消息,需要诱导WebDriverWait使所需元素可见,并且可以使用以下解决方案:

String text=driver.findElement(By.xpath("//your locator")).getAttribute("innerText");

您可以尝试
getAttribute(“数据原始标题”);
请将此格式化的html代码附加到您的初始帖子中。谢谢。
String text=driver.findElement(By.xpath("//your locator")).getAttribute("innerText");
new Actions(driver).moveToElement(element).perform();
String toolTipElement = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[@class='hasTooltip required' and @id='jform_email-lbl']"))).getAttribute("data-original-title");