Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SarahElson/8c1650cfbe42d8cacff70003e4704d2f to your computer and use it in GitHub Desktop.
Save SarahElson/8c1650cfbe42d8cacff70003e4704d2f to your computer and use it in GitHub Desktop.
How To Handle Authentication PopUps in Selenium WebDriver
package LocalGrid;
import org.openqa.selenium.By;
import org.testng.annotations.Test;
public class TestHandlingLoginPopUpUsingCredentials extends BaseTest {
@Test
public void testHandlingLoginPopUpUsingCredentials() {
String URL = "https://" + username + ":" + password + "@the-internet.herokuapp.com/basic_auth";
driver.get(URL);
String title = driver.getTitle();
System.out.println("The page title is : " + title);
String text = driver.findElement(By.tagName("p")).getText();
System.out.println("The text present in page is : " + text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment