我一直在努力点击一个按钮使用量角器。问题是,即使驱动程序发现元素,但它仍然不会单击它。任何帮助是提前感谢。量角器无法点击按钮,即使它发现它
下面是按钮为标志的HTML:
div class="row mod-form-button">
<button id="sign_in" class="mod-main" tabindex="4">Sign in</button>
</div>
<div class="row">
<div class="row">
<span class="nowrap">Not a member yet?</span>
<a class="nowrap" data-component="spinner" id="create_account"
href="create_account?client_id=UDPWeb1&callback=https%3A%2F%2F-na1-stg1.login.com">
Get an Test ID</a>
</div>
量角器代码: 这是规范文件: // spec.js
describe(' Demo', function() {
it('Should Login to Demo Site', function() {
browser.waitForAngularEnabled(false);
browser.get('https://stage.com');
// var EC = protractor.ExpectedConditions;
// Waits for the element with id 'abc' to be clickable.
//browser.wait(EC.elementToBeClickable($('password')), 5000);
element(by.id('password')).sendKeys('123456');
element(by.id('username')).sendKeys('[email protected]');
//browser.sleep(35000);
var EC = protractor.ExpectedConditions;
// Waits for the element with id 'abc' to be clickable.
element(by.id('sign_in')).click();
browser.sleep(5000);
var el = element(by.id('sign_in'));
browser.executeScript('arguments[0].scrollIntoView()', el.getWebElement());
el.click();
// browser.wait(EC.elementToBeClickable($('sign_in')), 5000);
//browser.wait(EC.elementToBeClickable($('.btn.coral-btn.coral-btn-primary')), 5000);
//element(by.css('.btn.coral-btn.coral-btn-primary')).click();
// expect(element(by.binding('latest')).getText()).
// toEqual('5'); // This is wrong!
});
});
这是配置文件: //Config.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
allScriptsTimeout: 5000000,
specs: ['specs.js']
}
感谢塔拉斯,我已经使用了上述解决方案,它不work.Also该元素存在,否则它会给出和元素不存在异常。 – Rahul