protractor : unable to click the button

前端 未结 2 1407
日久生厌
日久生厌 2021-01-23 03:32

Im new to protractor e2e testing. Writing jasmine test cases using protractor. I have two buttons in a html file. I want to select the specific button(button in begin.html file)

相关标签:
2条回答
  • 2021-01-23 04:13

    Try:

    element(by.buttonText('Start')).click();
    

    otherwise please send what error you have got.

    0 讨论(0)
  • 2021-01-23 04:32

    Protractor works fast and asynchronous. So, your button click might just be executed even before the page is ready and hence you get errors. To resolve this issue you can first try to find the element using wait function in protractor and then using the promise that the wait returns, you can click on the button.

    Below code might help you -

    var elementToClick = $('#gotest');
    browser.wait(protractor.ExpectedConditions.elementToBeClickable(elementToClick), 10000)
    .then ( function () {
        elementToClick.click();
    });
    

    Hope this solved your problem.

    0 讨论(0)
提交回复
热议问题