Javascript 如何为几秒钟内消失的通知获取xpath?
如何获取错误消息:-交易中的身份验证错误请与您的帮助台联系 这是我的复制元素:Javascript 如何为几秒钟内消失的通知获取xpath?,javascript,java,selenium,xpath,Javascript,Java,Selenium,Xpath,如何获取错误消息:-交易中的身份验证错误请与您的帮助台联系 这是我的复制元素: <div class="alert alert-error dismissible" role="alert" data-rendered="true" style="overflow: hidden; height: 5.74723px; padding-top: 1.43681px; margin-top: 0px; padding-bottom: 1.43681px; margin-botto
<div class="alert alert-error dismissible"
role="alert"
data-rendered="true"
style="overflow: hidden; height: 5.74723px;
padding-top: 1.43681px; margin-top: 0px;
padding-bottom: 1.43681px;
margin-bottom: 0px;"><button class="icon-dismiss" aria-label="Dismiss" type="button"></button>
<p><strong>Error: </strong>authentication error with Transaction contact your help desk</p></div>
错误:交易身份验证错误请联系您的技术支持
我希望xpath下方的xpath在chrome浏览器中正常工作
//div/p/text()
要获取错误消息
交易验证错误,请联系您的技术支持
,您可以使用以下代码块:
String text = driver.findElement(By.xpath("//div[@class='alert alert-error dismissible']//p")).getAttribute("innerHTML");
String[] my_text = text.split("(?=authentication)");
System.out.println(my_text[1]);
在这里要求解决方案不是一件好事,我们看到了您的解决方案,也看到了它不起作用的原因。欢迎使用堆栈溢出!请参阅:SO的期望是,用户提问时不仅要进行研究以回答自己的问题,还要分享研究、代码尝试和结果。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!另请参阅:感谢您的代码,它正在工作。