选择翻译从量角器右键菜单选项 [英] Selecting translate option from right click menu in Protractor
问题描述
我想通过点击转换从右键点击浏览器菜单选项页面把英文翻译。到目前为止,我的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('点击翻译');
});
希望它能帮助
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
这篇关于选择翻译从量角器右键菜单选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!