Handling OS Window Apps in Selenium


In Selenium at times we need to control some OS windows such as Alerts/ Notepad/ Calculator/ Download Popup etc.

As we know selenium doesn't work with OS apps it works only in browser. So for this there is a class in JAVA which can be used with selenium to intract with this OS Apps.

Robot class methods can be used to interact with keyboard / mouse to handle OS apps while doing automation using selenium.

Syntax:

Robot robot = new Robot();

//This will press arrow UP key in keyboard

robot.keyPress(KeyEvent.VK_UP);

//This will press Right click on mouse

robot.mousePress(InputEvent.BUTTON3_DOWN_MASK)

//This will hover mouse to the selected point on x,y coordinate.

robot.mouseMove(point.getX(), point.getY())

//This will press Enter on keyboard

robot.keyPress(KeyEvent.VK_ENTER))

//This will press Tab on keyboard

robot.keyPress(KeyEvent.VK_TAB))

There many other useful methods but this are common whileinteracting with OS apps.

So just use this in your Selenium code and interact with OS Apps.

We can use AutoIT too but it can only be used in Windows and we need to run our code across any OS.


要查看或添加评论,请登录

Dezlearn Education的更多文章

  • Introduction to JavaScript

    Introduction to JavaScript

    What is JavaScript? JavaScript is a cross-platform, object-oriented scripting language used to make interactive…

  • SelectorsHub

    SelectorsHub

    What is SelectorsHub? SelectorsHub is a free-to-use browser extension that auto-suggests all the possible combinations…

社区洞察

其他会员也浏览了