# Cannot access Browser Login prompt/dialog

**URL:** <https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [February 2, 2021, 3:21pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753 "2021-02-02T15:21:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 2, 2021, 3:21pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/1 "2021-02-02T15:21:15Z")

</div>

Hi,

When I access the login page for a network device, a credentials popup opens as shown below. Katalon studio does not record actions or we cannot do any spy object within this window.Is this because that window is not a web element? I am using Katalon Studio web version 7.7.2. Thanks.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/d/e/de4af70a413702f2a28610d3693909a5212771c2.png)

---

<div class="post-metadata">

**Author:** ![gsp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gsp/32/20464_2.png) [@gsp](https://forum.katalon.com/u/gsp)\
**Post date:** [February 2, 2021, 6:46pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/2 "2021-02-02T18:46:55Z")

</div>

hope this helps you [browserpopup](https://docs.katalon.com/katalon-studio/docs/pop_up_dialog_issue.html)

> [@Browser popups handling](http://forum.katalon.com/t/browser-popups-handling/20140):
>
> In our application after giving credentials and click on login button, there is certificate popup comes in where users need to click on OK to continue. When I am spying for objects, tool is not identifying the popups. How to handle in this situation…

add in your script

```auto
import java.awt.Robot as Robot
import java.awt.event.KeyEvent as KeyEvent

def th = new Thread((({
for (i = 0; i < 10; i++) {
Robot robot = new Robot()
Thread.sleep(5000)
robot.keyPress(KeyEvent.VK_ENTER)
Thread.sleep(1000)
break
}
}) as Runnable))

and add below code just before the action where popup displays

th.start()

```

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 4, 2021, 7:01pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/3 "2021-02-04T19:01:36Z")

</div>

Hello, i have followed your recommendation above but it fails after the th.start() line. Here is my code:

@Keyword  
def activateSCP(result,username,password){

```
	def th = new Thread((({
		for (i = 0; i < 10; i++) {
			Robot robot = new Robot()
			Thread.sleep(5000)
			robot.keyPress(KeyEvent.VK_ENTER)
			Thread.sleep(1000)
			break
		}
	}) as Runnable))

	//Enter username and password
	WebUI.executeJavaScript('window.open();', [])
	String currentWindow = WebUI.getWindowIndex()
	//Go in to new tab
	WebUI.switchToWindowIndex(currentWindow + 1)
	WebUI.navigateToUrl(GlobalVariable.activationURL)

	th.start()

	WebUI.click(findTestObject(inputUsername))
	WebUI.setText(findTestObject(inputUsername),username)
	WebUI.click(findTestObject(inputPassword))
	WebUI.setText(findTestObject(inputPassword),password)
	WebUI.click(findTestObject(signIn))
	//Click on activation field
	WebUI.click(findTestObject(inputActivationCode))
	WebUI.setText(findTestObject(inputActivationCode),result)
	WebUI.click(findTestObject(activateButton))
	//Coming back
	WebUI.switchToWindowIndex(currentWindow)
	//Verify that the camera has been enrolled
}

```

FYI, it says it cannot find the test object. That is normal because i cannot spy on that object. Is there a solution/workaround for this? Thanks.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 12:47pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/4 "2021-02-08T12:47:47Z")

</div>

Hello,

Any comments on this? Thanks.

---

<div class="post-metadata">

**Author:** ![gsp](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gsp/32/20464_2.png) [@gsp](https://forum.katalon.com/u/gsp)\
**Post date:** [February 8, 2021, 2:46pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/5 "2021-02-08T14:46:25Z")

</div>

I m sorry for delay, not sure why it is not identifying the popup, can you try on another browser. if still face the issue, ask your developers (try to enable popup) . let me know what they say thanks

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 3:12pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/6 "2021-02-08T15:12:06Z")

</div>

Hi, it does not work on edge also. I think the reason is because this is not an html popup.If i right click on any element, i cannot inspect.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 8, 2021, 3:15pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/7 "2021-02-08T15:15:40Z")

</div>

> [@mgrandillo](#):
>
> it says it cannot find the test object

What is “it”?

Always include the complete error message.

* * *
 

Aside: It is my strong belief that when writing test case code, there are very, **_very_** few situations where threading is a requirement or even a benefit. So few, in fact, I have never come across one.

If you don’t need added complexity, _don’t add it_.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 3:18pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/8 "2021-02-08T15:18:08Z")

</div>

Basically, when I select the spy web to spy on any object in that popup, I dont have the option to capture the object. Even if I record a test case, it will not record any actions on any object within that popup.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 8, 2021, 3:19pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/9 "2021-02-08T15:19:34Z")

</div>

You posted that statement beneath Test Case code. Therefore, what the Spy tool does is irrelevant.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 3:26pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/10 "2021-02-08T15:26:43Z")

</div>

Ok lets ignore the code, I was using that code because it was suggested to me to fix the problem. Let’s recap. I have an HTML URL (see below) that I would need to access to change something within that web page. When I access the web page, a credentials popup is shown (See below). Katalon Studio web will not let me do a spy object on any of the elements within that popup (eg: username/password, sign In, etc). That is the issue I am encountering. Any thoughts? comments?

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/e/3ef97fa188cd59588fb9c310784ec6a1f84c5656.png)

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 8, 2021, 3:40pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/11 "2021-02-08T15:40:35Z")

</div>

I see no reason why Robot wouldn’t work there, as long as you get the timing right (I noticed you need to switch windows/tabs). Be sure you arrive at the new window in a timely manner and run the robot code. To move from Name to Password, use a Tab key.

My advice, remove the thread stuff but keep the closure (everything between `{` and `}`) and call it from your test case at the correct step position (i.e. after the new window/tab is open and ready).

Lastly, let’s see if we can get @Brandon_Hein to take a look - I think he posted something relevant to basic auth dialogs a while back…

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 5:37pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/12 "2021-02-08T17:37:51Z")

</div>

From within the robot code, I fail to see where the actually setting of the username and password is done. Note that I have copied the code given to me exactly as is.DO i need to adapt it to my needs?  
It is currently failing at where the setText command is ran. This is because it cannot find the object. DO i need to include this somehow in the robot part of the code? If so, how? Thanks.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/d/3d688b4cd8fa3208e477a83a1351961d54eb8709.png)

@Keyword  
def activateSCP(result,username,password){  
//Enter username and password  
WebUI.executeJavaScript(‘window.open();’, )  
String currentWindow = WebUI.getWindowIndex()  
//Go in to new tab  
WebUI.switchToWindowIndex(currentWindow + 1)  
WebUI.delay(5)  
int i  
def th = new Thread((({  
for (i = 0; i \< 10; i++) {  
Robot robot = new Robot()  
Thread.sleep(5000)  
robot.keyPress(KeyEvent.VK\_ENTER)  
Thread.sleep(1000)  
break  
}  
}) as Runnable))

```
	th.start()

	WebUI.navigateToUrl(GlobalVariable.mobotixActivationURL)
	WebUI.setText(findTestObject(inputUsername),username)
	WebUI.click(findTestObject(inputPassword))
	WebUI.setText(findTestObject(inputPassword),password)
	WebUI.click(findTestObject(signIn))
	//Click on activation field
	WebUI.click(findTestObject(inputActivationCode))
	WebUI.setText(findTestObject(inputActivationCode),result)
	WebUI.click(findTestObject(activateButton))
	//Coming back
	WebUI.switchToWindowIndex(currentWindow)
	//Verify that the camera has been enrolled

}

```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 8, 2021, 5:54pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/13 "2021-02-08T17:54:11Z")

</div>

In essence, the Robot API targets the OS, just like a user does when (s)he uses the keyboard or mouse - no user ever has to specify the text input directly, they type into the control with focus, or set it first with a click. Then the OS directs the keyboard keys to the control.

See?

That’s why I said, _as long as you get the timing right_ and _Be sure you arrive at the new window in a timely manner_. The dialog _should_ be allowed time to appear, THEN you can execute the Robot code.

Again - that thread stuff is NOT included in my advice. I’m working under the assumption it’s not there.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 6:00pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/14 "2021-02-08T18:00:31Z")

</div>

Sorry i’m confused. How is the text set in the username/password fields? What am I missing in the code I provided? Right now it just shows the sign-in popup and stops there. Thanks.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 6:20pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/15 "2021-02-08T18:20:37Z")

</div>

I removed the thread stuff, here is what my code looks like. Also, the for look iterates 10 times, not sure what that is for to be honest. I used this code as suggested in my script. What do i need to do to adapt it to my test case? Ie: login to the web page with credentials.  
Thanks.

@Keyword  
def activateSCP(result,username,password){  
//Enter username and password  
WebUI.executeJavaScript(‘window.open();’, [])  
String currentWindow = WebUI.getWindowIndex()  
//Go in to new tab  
WebUI.switchToWindowIndex(currentWindow + 1)  
WebUI.delay(5)  
int i  
//def th = new Thread((({  
for (i = 0; i \< 10; i++) {  
Robot robot = new Robot()  
[//Thread.sleep](https://Thread.sleep)(5000)  
[//robot.keyPress](https://robot.keyPress)(KeyEvent.VK\_ENTER)  
[//Thread.sleep](https://Thread.sleep)(1000)  
break  
}  
//}) as Runnable))

```
	//th.start()

	WebUI.navigateToUrl(GlobalVariable.mobotixActivationURL)
	//WebUI.click(findTestObject(inputUsername))
	WebUI.setText(findTestObject(inputUsername),username)
	WebUI.click(findTestObject(inputPassword))
	WebUI.setText(findTestObject(inputPassword),password)
	WebUI.click(findTestObject(signIn))
	//Click on activation field
	WebUI.click(findTestObject(inputActivationCode))
	WebUI.setText(findTestObject(inputActivationCode),result)
	WebUI.click(findTestObject(activateButton))
	//Coming back
	WebUI.switchToWindowIndex(currentWindow)
	//Verify that the camera has been enrolled

}
```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [February 8, 2021, 6:20pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/16 "2021-02-08T18:20:48Z")

</div>

Like you said, you need to adapt that code for your purposes.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 6:31pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/17 "2021-02-08T18:31:29Z")

</div>

Yes I am aware of that. I would like to know how do i set text in the username/password field using the robot code? I haven;t found anything to help me with this. I was hoping I would get help from someone in the forum. Thanks.

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [February 8, 2021, 7:02pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/18 "2021-02-08T19:02:37Z")

</div>

Back in the day, we used to do something like this:

`driver.get("http://username:password@www.example.com");`

i.e. you provide the login credentials in the app URL. I’m not sure if this works anymore, but you could give it a try.

---

<div class="post-metadata">

**Author:** ![mgrandillo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mgrandillo/32/16104_2.png) [@mgrandillo](https://forum.katalon.com/u/mgrandillo)\
**Post date:** [February 8, 2021, 7:28pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/19 "2021-02-08T19:28:58Z")

</div>

Hi Brandon, thanks for the tip. When I specify driver.get it shows it as underlined. Do i need to import something? Thanks

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/4/0/40473699a996382fd15195723264d3116b5dd89b.png)

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [February 8, 2021, 7:31pm UTC](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753/20 "2021-02-08T19:31:18Z")

</div>

Yes, you need to get the driver instance like so:

`def driver = DriverFactory.getWebDriver()`

Once you enter this line of code, press ctrl + shift + o on your keyboard to organize the necessary imports.

[Next page](https://forum.katalon.com/t/cannot-access-browser-login-prompt-dialog/51753.md?page=2)
