# Authenticate method doesn’t detect BtnOK in a popup

**URL:** <https://forum.katalon.com/t/authenticate-method-doesn-t-detect-btnok-in-a-popup/6109>\
**Category:** Miscellaneous\
**Created:** [September 5, 2017, 11:35am UTC](https://forum.katalon.com/t/authenticate-method-doesn-t-detect-btnok-in-a-popup/6109 "2017-09-05T11:35:48Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Mark\_Fridman](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@Mark\_Fridman](https://forum.katalon.com/u/Mark_Fridman)\
**Post date:** [November 26, 2017, 2:10pm UTC](https://forum.katalon.com/t/authenticate-method-doesn-t-detect-btnok-in-a-popup/6109/9 "2017-11-26T14:10:16Z")

</div>

Hi everyone i’ve managed to come around this problem and to solve it using the java Robot with a custom keyword

`  
import java.awt.Robot  
import java.awt.Toolkit  
import java.awt.datatransfer.StringSelection  
import java.awt.event.KeyEvent

public class Authenticate {  
@Keyword  
def loginAuthenticate(String username, String password) {  
Robot robot = new Robot();  
robot.setAutoDelay(250);  
StringSelection ss = new StringSelection(username);  
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);  
robot.keyPress(KeyEvent.VK\_CONTROL);  
robot.keyPress(KeyEvent.VK\_V);  
robot.keyRelease(KeyEvent.VK\_V);  
robot.keyRelease(KeyEvent.VK\_CONTROL);  
robot.keyPress(KeyEvent.VK\_TAB);  
robot.keyRelease(KeyEvent.VK\_TAB);  
ss = new StringSelection(password);  
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);  
robot.keyPress(KeyEvent.VK\_CONTROL);  
robot.keyPress(KeyEvent.VK\_V);  
robot.keyRelease(KeyEvent.VK\_V);  
robot.keyRelease(KeyEvent.VK\_CONTROL);  
robot.keyPress(KeyEvent.VK\_TAB);  
robot.keyRelease(KeyEvent.VK\_TAB);  
robot.keyPress(KeyEvent.VK\_ENTER);  
robot.keyRelease(KeyEvent.VK\_ENTER);  
}  
}  
`

---

_[View the full topic](https://forum.katalon.com/t/authenticate-method-doesn-t-detect-btnok-in-a-popup/6109)._
