如何查找显示为<;的工具提示文本消息;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"> *</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");