gpt4 book ai didi

javascript - Protractor - 在 chrome 中右键单击显示错误的菜单

转载 作者:行者123 更新时间:2023-11-28 06:41:51 25 4
gpt4 key购买 nike

在 Chrome 中手动测试上下文菜单时,结果符合预期:expected right click menu

但是当 Protractor 尝试模仿相同的情况时,浏览器的菜单出现: unexpected right click menu

我用来触发菜单的代码如下:

browser.actions().mouseMove(element(by.id(word2Id))).perform();
browser.actions().click(protractor.Button.RIGHT).perform();

任何人都可以提出解决此问题的方法或解决方案吗?因为我现在很困惑。

编辑:在鼠标移动之前和之后添加 sleep 使测试有时有效。我将 sleep 时间更改为 10 秒,但没有任何改善。我在下面添加了一个测试(有些代码很奇怪,因为我删除了方法调用)。

var module = testData.modules[3];
loginPage.login(process.env.TDC_TEST_USER, process.env.TDC_TEST_PASS);

var url = resourcePage.buildModuleResourceUrl(module._id, module.resources[1], "title");
url = TestConfig.BASE_URL + "/test/iframe?url=" + encodeURIComponent(url) + "&width=991px&height=1000px";
browser.driver.get(url);

// load the module/resource in a iframe to simulate a small screen
browser.switchTo().frame(browser.driver.findElement(by.id("embeddedPlayerFrame")));
expect(element(by.id("btnClassCommentsLeftPanel")).getAttribute("class")).toContain("active");
expect(element(by.id("btnPersonalCommentsLeftPanel")).getAttribute("class")).not.toContain("active");

var type = "personal";
var startWordIndex = 11;

var pagedMenuBtn = type === "class" ? "pagedMenuClassComment" : "pagedMenuPersonalNote";
var saveBtnTxt = type === "class" ? "Comment" : "Create Note";
var word1Id = "ocr_word_0_" + startWordIndex;
var word2Id = "ocr_word_0_" + (startWordIndex + 1);
var word3Id = "ocr_word_0_" + (startWordIndex + 2);

expect(element(by.id(word1Id)).isDisplayed()).toBe(true);
expect(element(by.id(word2Id)).isDisplayed()).toBe(true);
expect(element(by.id(word3Id)).isDisplayed()).toBe(true);

browser.actions()
.mouseDown(element(by.id(word1Id)))
.mouseMove(element(by.id(word1Id)))
.mouseMove(element(by.id(word2Id)))
.mouseMove(element(by.id(word3Id)))
.mouseUp(element(by.id(word3Id)))
.perform();

browser.sleep(1000);
browser.actions().mouseMove(element(by.id(word2Id))).perform();
browser.sleep(100);

// create a new class comment annotation by right clicking
browser.actions().click(protractor.Button.RIGHT).perform();

编辑:这在 Firefox 中完美运行,但在 Chrome 中不起作用

最佳答案

尝试在鼠标操作之前使用 browser.sleep('somemilliseconds') 或在此处显示完整代码。

关于javascript - Protractor - 在 chrome 中右键单击显示错误的菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33722840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com