当我在量角器中运行测试时,我收到了错误消息 信息 : 失败:元素不可见
无论如何都要找到哪个元素不可见?
堆栈: ElementNotVisibleError:元素不可见 (会议信息:chrome = 56.0.2924.87) (驱动程序信息:chromedriver = 2.26.436362(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform = Windows NT 6.3.9600 x86_64)(警告:服务器未提供任何堆栈跟踪信息)
CONF:
{
seleniumServerJar: null,
seleniumPort: null,
chromeDriver: null,
seleniumArgs: [],
sauceUser: null,
sauceKey: null,
seleniumAddress: null,
suites: {
login:'./common/login.js',
create_item:'./businessScenarios/create_an_item.js',
regressionTest:[
'./common/login.js',
'./businessScenarios/create_an_item.js',
]
},
allScriptsTimeout:3000000,
capabilities:{
'browserName': 'chrome',
'chromeOptions': {
'args': ['no-sandbox','no-default-browser-check','no-first-run','disable-default-apps']
}
},
jasmineNodeOpts: {
showColors:true,
defaultTimeoutInterval: 3000000,
// onComplete will be called just before the driver quits.
onComplete: null,
// If true, display spec names.
isVerbose: false,
// If true, include stack traces in failures.
includeStackTrace: true
},
params: {
login: false,
uname:'user',
pwd:'pwd'
},
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: './protractor-result',
takeScreenshots: false
})
);
},
rootElement: 'body'
}
spec.js
browser.executeScript("$('#toast-container').remove();");
element.all(by.css('.dx-datagrid-table')).all(by.css('.dx-data-row')).get(0).click().then(function() {
element.all(by.css('.dx-row.dx-data-row.dx-column-lines.bold_item.dx-selection')).first().click().click().then(function() {
var currentUrl = browser.driver.getCurrentUrl();
expect(currentUrl).toMatch('/itemMaintenance/edit');
browser.sleep(2000);
browser.executeScript("$('#toast-container').remove();");
var family = element.all(by.css('.selectize-input')).get(4);
family.isPresent().then(function(value) {
if (value) {
family.click().then(function() {
browser.sleep(12222);
element.all(by.css('.selectize-input input')).get(4).sendKeys(121212);
browser.sleep(10000);
var content = element.all(by.css('.selectize-dropdown-content')).get(0);
content.all(by.css('.option')).get(1).click();
browser.sleep(2000);
});
}
});
});
browser.sleep(1000);
});
答案 0 :(得分:0)
如果您单击的元素应该是可见的并且应该在页面上(不是条件外观或随机性),那么您可以这样做:
class