簡體   English   中英

Protractor actions().mouseMove 命令不適用於 firefox 和 IE,對於 chrome 它工作正常

[英]Protractor actions().mouseMove command not working for firefox and IE, for chrome it works fine

我一直在使用操作類命令 mouseMove 時出錯。 只有當我在 Firefox 和 IE 上運行腳本時才會出現錯誤,使用 chrome 可以正常工作。

這是我嘗試過的代碼:

browser.get("https://chercher.tech/practice/popups")
        // mouse hover on a submenu
        browser.actions().mouseMove(element(by.id("sub-menu"))).perform()

提前致謝 :)

“動作”功能多年來一直困擾着壁虎驅動程序。 您可以在 Github 中找到大量未解決的問題。 你現在可以使用這個包(它也包括 mouseMove) https://www.npmjs.com/package/protractor-firefox-support

最糟糕的部分是,很可能您將不得不復制所有將在其中使用 Firefox 鼠標操作的規范文件......也許有人會想出一些關於如何檢測瀏覽器或傳遞一些變量的奇特解決方案取決於你的能力

嘗試使用:

await browser.executeScript('arguments[0].scrollIntoView(true)', avatarButton);

其中 avatarButton 是一個選擇器

您可以使用 dispatchEvent (這適用於 Chrome 和 Firefox)。

it('tests tooltip on button with id myFirstButton', async() => {
    const button = await element(by.id('myFirstButton'));
    await browser.executeScript(`var ev = new MouseEvent('mouseenter');`
                                + 'arguments[0].dispatchEvent(ev);', button);
    /* now the tooltip should be visible ... */
    ...
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM