Im facing signIn alert whenever right after my application launching in the browser, but im unable to enter the values or accept the alert since it’s says ‘No alert found after 10 second(s). ’
Code:
KeywordUtil.logState()
WebUI.openBrowser(url)
WebUI.delay(3)
WebUI.waitForAlert(10)
//WebUI.maximizeWindow(FailureHandling.OPTIONAL)
WebUI.acceptAlert()
Alert:
Error:
1 Like
This dialog is displayed because the URL requires you to provide the username and password for Basic Authentication. To do that, you should use
The WebUI.acceptAlert() keyword is not relevant to Basic Auth.
@kazurayam This method doesn’t work for me
Code:
KeywordUtil.logState()
WebUI.openBrowser('')
WebUI.delay(3)
WebUI.authenticate(url, userName, password, 10)
//WebUI.maximizeWindow(FailureHandling.OPTIONAL)
WebUI.acceptAlert()
Error:
Please read the error message.
The webpage at https://… might be temporarilly down or it may have moved permanently to a new web address.
You hid the URL string, so I can’t see anymore about this error.
You should be able to find the reason why you got it.
depapp
December 26, 2024, 2:16pm
5
hey @royan.joseph
i have got the simplest solution for this kind of issue: basic auth
.
i have implemented it in my own project.
here’s what you need to do: add the basic auth credentials directly to the URL.
for example:
your basic auth credentials:
Username: johndoe
Password: p455w0rd
if your URL is https://example.com
, you include the credentials like this:
https://johndoe:p455w0rd@example.com
it works perfectly on my side
No use @depapp webpage showing the login alert even if i send the credentials along with the URL.
depapp
January 2, 2025, 7:58am
7
Hmm, if it’s basic auth, it should work. I have tried it myself.
I’m just curious why it doesn’t work
@royan.joseph
Do you know if the alert was displayed because of the Basic Authentication? Or, is it because of any other reason?
I don’t know whether it’s for basic auth or normal one, how can i find that?
depapp
January 2, 2025, 9:17am
10
I think the easiest way is to try opening the full URL manually in your browser.
if the alert is appear (even you put the credentials on you full URL), I think it’s not the alert for the basic auth
1 Like
Please disclose the URL of your target. Otherwise, Is it a public URL on the Internet? Or is it a private one? Unless the URL is made public so that I can get access to it, I can not help you any more.
Try entering the credentials and click sign in button via robot library
use the below
public static void typeCredentials(String username, String password) {
pasteText(username);
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
Thread.sleep(500); // Wait for half a second
pasteText(password);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
} catch (Exception e) {
e.printStackTrace();
}
}
modify it as per your needs
pasteText() contains the default sendkeys code or it has some modified code @Monty_Bagati ?
public static void pasteText(String text) {
try {
StringSelection stringSelection = new StringSelection(text);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
} catch (Exception e) {
e.printStackTrace();
}
}
1 Like
One word of caution when you use Robot is that you cannot be using the keyboard or mouse when your test is running, as you could interfere with the Robot’s “attention” from what it’s trying to do.