我试图找到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&lang=en-JO&src=ym&.intl=xa&specId=yidReg&.done=https%3A%2F%2Fmail.yahoo.com&nr=1&step=2&.crumb=qP.UnkGzfkR&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");