-3

How can I close or How can I enter the UserId and password and click on Login?

This the alert code

how the alert looks like

Please help me in handling this alert

3 Answers3

2

You can use like this in JAVA:

driver.get("http://username:password@www.domain.com");
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
0

This may help you :-

String Password = URLEncoder.encode("pass");

String UserName= URLEncoder.encode("UserName");

String url = String.format("http://%s:%s@xyz", UserName, Password);

In this %s is variable which pass to url in form of parameter .

You can refer this url also https://serverfault.com/questions/371907/can-you-pass-user-pass-for-http-basic-authentication-in-url-parameters

Ankur Singh
  • 1,239
  • 1
  • 8
  • 18
0

Did you try desiredCapabilities?

This should close alert while in automated window

DesiredCapabilities dC= DesiredCapabilities.chrome()
dC.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.ACCEPT)