问题描述
更新:: 我尝试使用 sendKeys() 我在文本框中输入了一些奇怪的 5 或 66。附加图片。
sendKeys("2001 年 2 月 11 日(中欧夏令时)"); sendKeys("2001-02-23")
Screenshot of text box with 66.* value on sendkeys("2011-02-23")
出生日期输入元素(如附图所示)正在正确填写。但是,在移动到下一个控件时,dob 字段的值被隐藏或屏蔽。然后单击继续按钮,将引发验证错误。我附上了屏幕录制中这三个步骤的屏幕截图。下面是我试图访问 iframe 中的控件的 selenium 方法。在这方面的任何帮助将不胜感激。
public void confirmsPaymentWithKlarnaInvoice(){
klarnaInstantBuyButton.waitUntilEnabled().click();
switchToIFrame();
WebDriver driver = getDriver();
WebElement selectElem = driver.findElement(By.id("invoice_kp-purchase-approval-form-user-title"));
WebElement selectOpt = selectElem.findElements(By.tagName("option")).get(1);
selectElem.click();
selectOpt.click();
if(driver instanceof JavascriptExecutor) {
((JavascriptExecutor)driver).executeScript("arguments[0].value='23.01.2012'",klarnaInvoicedob);
}
klarnaInvoiceKpContinueButton.click();
klarnaInstantCheckoutSuccess.shouldBeVisible();
}
@FindBy(id="invoice_kp-purchase-approval-form-date-of-birth")
private WebElementFacade klarnaInvoicedob;
inframe里面的输入元素如下,
<input id="invoice_kp-purchase-approval-form-date-of-birth" name="dateOfBirth" type="tel" mask="DD.DD.dddd" placeholder="" maxlength="10" size="10" style="background-color: transparent; border: none; Box-sizing: border-Box; outline: none; Box-shadow: none; caret-color: rgb(72,123,148); color: rgb(23,23,23); -webkit-text-fill-color: rgb(23,23); opacity: 1; font-family: "Klarna Text","Klarna Sans",Helvetica,Arial,sans-serif; font-weight: 500; font-size: 16px; height: 60px; overflow: hidden; padding-left: 0px; padding-top: 18px; position: absolute; text-overflow: ellipsis; top: 0px; margin-left: -1px; margin-top: 2px; white-space: Nowrap; width: 100%; -webkit-font-smoothing: antialiased; text-rendering: geometricprecision;"/>
Screenshot of the control with value
Text box value hidden when it moves to next control
Validation error thrown on button click
P.S:即使我尝试在下拉后的输入框中输入,也是一样的。我有同样的验证错误。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)