我在页面上有一个提交按钮,允许用户在输入电子邮件后重设密码。我可以使用element.click(),element.submit()或按以下代码使用JS“成功”单击按钮:
@FindBy(xpath = ("//button[contains(text(), 'Send new password')]"))
private WebElement setNewPasswordButton;
public forgotPasswordPage clickSetNewPasswordButton(WebDriver driver)
{
//setNewPasswordButton.click();
//JavascriptExecutor js = (JavascriptExecutor)driver;
//js.executeScript("arguments[0].click();", setNewPasswordButton);
setNewPasswordButton.submit();
return this;
}
在Selenium中单击按钮时,我确实会看到下一页,上面写着“您应该收到一封电子邮件以重设密码”。 但是,我从未在收件箱中收到密码重置电子邮件。
当我手动运行该过程时,它始终可以正常工作,例如,一封电子邮件已发送到我的收件箱以重置密码。
我注意到的是,当我通过Selenium(使用上述三种方法中的任何一种)单击时,它几乎立即翻转到“您应该收到一封电子邮件来重置密码”页面。但是,当我手动运行测试时,在显示“您应该收到一封电子邮件...”页面之前,会有1-2秒的明显延迟。这向我表明,硒单击无法以某种方式启动密码重置功能。</ p>
有什么想法吗?谢谢。
根据要求添加HTML:
<div id="root" style="height: 100%;"><div data-reactroot="" style="height: 100%;"><span class="redux-toastr" aria-live="assertive"><span><div class="top-left"></div><div class="top-right"></div><div class="top-center"></div><div class="bottom-left"></div><div class="bottom-right"></div><div class="bottom-center"></div></span></span><!-- react-empty: 322 --><form class=""><div class="sc-kNBZmU iUcwTp"><img src="/f5ef6979404e3773b6d263adea9c4b5b.png" alt="Test logo" class="sc-iCwjlJ bZQcHn"></div><div class="mt-10 container"><div class="row"><div class="col-8 offset-2 col-lg-4 offset-lg-4"><div class="sc-cHGsZl pt-5 pb-4 hMshLY"><h1 class="text-center">Forgot password</h1></div><p class="text-center">Enter your email address and your password will be reset and emailed to you.</p><div><div class="form-group"><!-- react-text: 457 --><!-- /react-text --><input name="email" value="bobTest123+547547@gmail.com" placeholder="Email" class="form-control" type="text"></div><div class="sc-eopZyb iZMZhY"><button type="submit" class="sc-bdVaJa fVCJpx btn btn-primary">Send new password</button></div></div></div></div></div></form><div class="sc-jxGEyO llyLPV container"><div class="row"><div class="col-12"><div class="d-flex mt-5"><div class="mr-3"><strong>Test-ui-v2: </strong><span>0.83.5</span></div><div class="mr-3"><strong>styleguide: </strong><span>0.16.3</span></div></div></div></div></div></div></div>
<script type="text/javascript">
!function(){
var analytics=window.analytics=window.analytics||[];
if(!analytics.initialize) {
if(analytics.invoked) window.console&&console.error&&console.error("Segment snippet included twice.");else{
analytics.invoked=!0;
analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];
analytics.factory=function(t){
return function(){
var e=Array.prototype.slice.call(arguments);
e.unshift(t);
analytics.push(e);
return analytics
}
};
for(var t=0;t<analytics.methods.length;t++){
var e=analytics.methods[t];
analytics[e]=analytics.factory(e);
}
analytics.load=function(t){
var e=document.createElement("script");
e.type="text/javascript";
e.async=!0;
e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";
var n=document.getElementsByTagName("script")[0];
n.parentNode.insertBefore(e,n)};
analytics.SNIPPET_VERSION="3.1.0";
analytics.load("lRqYQgiwd78XM7uLT8ECR3Cv4dPEDalH");
}
}
}();
</script>
<script src="https://www.google.com/recaptcha/api.js"></script>
道歉的格式。