首页 > 解决方案 > 量角器元素在点 (x, y) 处不可点击

问题描述

这是我一段时间以来最沮丧的一次。我正在用 Javascript(量角器)编写测试,我只想让它点击我页面上的元素。可能有 10%(或更少)的时间它实际正常工作,另外 90% 的时间我得到这个错误:

Failed: element click intercepted: Element is not clickable at point (x,y)

是的。我看过其他关于这个的帖子,我已经尝试了所有的“解决方案”,但没有一个能让它 100% 的工作。

it('Full Width Video test', async() => {
        const fwv = await blocks.fullWidthVideo;
        
        browser.executeScript("arguments[0].scrollIntoView(true);", fwv);
        await expect(await fwv).toBeDisplayed();
        await expect(await blocks.fullWidthVideoImg).toBeDisplayed();
        
// tried this
        // browser.manage().timeouts().implicitlyWait(10000) 

// also tried this     
        // const EC = new protractor.ProtractorExpectedConditions();
        // await browser.wait(EC.elementToBeClickable(
        //     element(blocks.fullWidthVideoImg))), 
        //     5000,' item is not clickable after 5 seconds');

// also also tried this
        // let ele = browser.findElement(blocks.fullWidthVideoImg));
        // browser.actions().mouseMove(ele).click().perform();

        await blocks.fullWidthVideoImg.click();
        await expect(await blocks.fullWidthVideoIframe).toBeDisplayed();
    });
export class Blocks { 
// Full Width Video
    get fullWidthVideo() {
        return element(by.xpath('//div[@data-test="fullwidthvideo"]'))
    }

    get fullWidthVideoImg() {
        const fwv = this.fullWidthVideo;
        return fwv.element(by.xpath('./div[@data-test="video-img"]')))
    }

    get fullWidthVideoIframe() {
        const fwv = this.fullWidthVideo;
        return fwv.element(by.xpath('./div[@data-test="video-iframe"]')))
    }
}

标签: javascriptautomated-testsprotractorclick

解决方案


推荐阅读