Selenium click right on mouse or press option key form keyboard

半腔热情 提交于 2019-12-05 10:55:52

问题


Using selenium how can I click on the right click of mouse or press on the option key from keyboard(This key is usually available between right ALT and CTRL key)


回答1:


If you are trying to open the context menu, there is a selenium.contextMenu(locator) . This is the menu that opens up when you right click or press that option key.

This example shows you how to open a page element in a new tab from context menu. The page used for example is seleniumhq.org. This code will right click on the logo link and open the page in a new tab

selenium.contextMenu(link=Selenium);

//In the below line of code "t" is the shortcut to open the page in a new tab
selenium.keyPress("link=Selenium","t");

Hope this helps.



来源:https://stackoverflow.com/questions/6176033/selenium-click-right-on-mouse-or-press-option-key-form-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!