硒在输入文本框中输入的值在运行时不可见,因此测试失败
按照测试步骤运行测试时,将在“输入”文本框中输入该值,但是当其移至最后一个文本框时,先前的文本框值将不可见,并且文本框看起来为空。因此测试失败,因为无法继续。
硒:2.53.0 Firefox:45
代码:
getDriver().switchTo().frame(
getDriver().findElement(
By.xpath("//iframe[@src='/bi-sac-config-mgr/SMTP']")));
if (!waitForObject("psm_nhp_mailsave", m_largeTime * 2)) {
getLogger().error("Save mail settings unavailable");
} else {
waitForObject("psmsacmailserverxpath", m_largeTime * 2);
setObject("psmsacmailserverxpath",
"internal-mail-router.gmail.com");
waitForObject("psmsacmailportxpath", m_largeTime * 2);
setObject("psmsacmailportxpath", "25");
waitForObject("psmsacmaildisplaynamexpath", m_largeTime * 2);
setObject("psmsacmaildisplaynamexpath", "matstest");
waitForObject("psmsacmailemailxpath", m_largeTime * 2);
setObject("psmsacmailemailxpath", "matstest@gmail.com");
在上面的代码中,输入psmsacmailserverxpath
(它是必填文本字段)后,该值在运行时消失。手动工作正常。在使用Selenium的自动化中,可以看到此问题。
html元素:
<input id="mail-server-input" class="oj-form-control oj-inputtext oj-inputtext-input oj-component-initnode" data-bind="ojComponent: {component: 'ojInputText',
invalidComponentTracker: tracker,
value:smtpConfig.host,
required: true,
validators: [{type: 'length',
options: {min: 0,
max: 250,
hint:null}}],
displayOptions:{validatorHint: 'none'}}" type="text" placeholder="" aria-invalid="false" aria-required="true">