Panee S
Panee S

Reputation: 104

Element is not clickable at point in protractor using TypeScript

Below is my code which I've tried to avoid the error but it doesn't clicks the element or throws any more errors. Please help in correcting the code.

async testMethod() {
    let button = element( by.cssContainingText('span.mat-button-wrapper','abc'));
    await browser.wait(until.visibilityOf(button), this.DEFAULT_WAIT_TIME_SECONDS * 1000, 'failed to click the button!');
    button.getText().then((text)=>{
        console.log('Get the text of the ele: ' + text.toUpperCase());
         expect(text.toUpperCase()).toEqual(expectedValue);
    });

    await browser.manage().window().setSize(1000, 1000);
    await browser.executeScript('window.scrollTo(0,document.body.scrollHeight)').then(()=>{
         browser.actions().mouseMove(button).perform();
        browser.sleep(10000);
    });

    /* await browser.executeScript("arguments[0].style.visibility = 'visible';",
       "arguments[0].style.display = 'block';",
       "arguments[0].scrollIntoView();",
       button.getWebElement());
    */
       browser.actions().mouseMove(button).perform();
       browser.sleep(5000);
}

Upvotes: 0

Views: 295

Answers (1)

Panee S
Panee S

Reputation: 104

Below is the working code if anybody needs it. Share if there is a better implementation of it

async testMethod() {
    let button = element( by.cssContainingText('span.mat-button-wrapper','abc'));
    await browser.wait(until.visibilityOf(button), this.DEFAULT_WAIT_TIME_SECONDS * 1000, 'failed to click the button!');
    button.getText().then((text)=>{
        console.log('Get the text of the ele: ' + text.toUpperCase());
         expect(text.toUpperCase()).toEqual(expectedValue);
    });
         await browser.executeScript('window.scrollTo(0,document.body.scrollHeight)').then(()=>{
            browser.sleep(2000);
    });

        button.click();
}

Upvotes: 1

Related Questions