如何在外部div中找到带有标记警报的元素

时间:2017-05-11 21:15:06

标签: javascript java selenium-webdriver webclient htmlunit

我试图找到this page中的元素并将它放在Objects(DomElement)中对它进行一些测试,问题出在elemnt reg-error-yid它是div -id字段内的div-div -suggestion,我试图getElementById,byName,byXPath和getFirstByXPath它都不起作用,我也尝试用WebDriver更改webClient并使用driver.findElement(By.className("oneid-error-message"))它也无法正常工作

已注册消息的内容

<div id="reg-error-yid" class="oneid-error-message" data-error="messages.IDENTIFIER_EXISTS" role="alert">A Yahoo account already exists with this email address. <a href="https://login.yahoo.com/?intl=xa&amp;lang=en-JO&amp;src=ym&amp;.intl=xa&amp;specId=yidReg&amp;.done=https%3A%2F%2Fmail.yahoo.com&amp;nr=1&amp;step=2&amp;.crumb=qP.UnkGzfkR&amp;login=abtallaldigital">Sign in</a>.</div>

我的代码

final HtmlPage page1 = webClient.getPage("https://login.yahoo.com/account/create?specId=yidReg&lang=en-JO&src=ym&done=https%3A%2F%2Fmail.yahoo.com&display=login&intl=xa");

             final DomElement firstName = page1.getElementById("usernamereg-firstName");
             final DomElement emailAddress = page1.getElementById("usernamereg-yid");
             final DomElement takenMsg = page1.getElementById("reg-error-yid");

0 个答案:

没有答案