选择翻译从量角器右键菜单选项量角器、右键菜单、选项

2023-09-13 03:47:24 作者:颠覆灬整个世界

我想通过点击转换从右键点击浏览器菜单选项页面把英文翻译。到目前为止,我的code是做正确的点击,但我不能选择翻译选项。

code:

 的console.log(那我应该用鼠标右键单击屏幕)browser.sleep(3000);browser.actions()的mouseMove(元素(by.id('搜索图标')))执行()。browser.actions()。点击(protractor.Button.RIGHT).perform()。然后(函数(){    的console.log('是点击右键进行的?'); 

解决方案

右键点击,点击浏览器上的转换生成的菜单是,量角器/硒不支持的事件。相反,如果你知道翻译右键点击产生的菜单上的选项,那么你可以使用箭头键的位置导航到它,然后preSS 输入收益键。下面是如何 -

假设如果翻译选项菜单中的第3,则发送 ARROW_DOWN 键三次 -

  browser.actions()的mouseMove(元素(by.id('搜索图标')))执行()。browser.actions().click(protractor.Button.RIGHT).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.RETURN).perform().then(function (){    browser.sleep(3000);    的console.log('点击翻译');}); 

希望它能帮助

EXCEL右键菜单没有 插入 选项了

I am trying to translate the page to English by clicking on translate option from right click browser menu. So far, my code is doing the right click, but I am not able to select the translate option.

Code:

console.log('Then I should right click on screen')
browser.sleep(3000);
browser.actions().mouseMove(element(by.id('search-icon'))).perform();
browser.actions().click(protractor.Button.RIGHT).perform().then(function () {
    console.log('Is right click performed ?');

解决方案

Right Click and clicking on the translate on the browser generated menu is an event that protractor/selenium doesn't support. Instead if you know the position of the translate option on the menu generated by right click, then you can use arrow keys to navigate to it and then press enter or return key. Here's how -

Suppose if the translate option is 3rd in the menu, then send the ARROW_DOWN key thrice -

browser.actions().mouseMove(element(by.id('search-icon'))).perform();
browser.actions().click(protractor.Button.RIGHT).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.ARROW_DOWN).sendKeys(protractor.Key.RETURN).perform().then(function () {
    browser.sleep(3000);
    console.log('Clicked on translate');
});

Hope it helps

 
精彩推荐
图片推荐