Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Handle Proxy Authentication using Alerts

Category: Selenium WebDriver
package HireQADemo;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class AlertsDemo {
    public static void main(String args[]) throws IOException {
        System.setProperty(""webdriver.chrome.driver"", ""D:\\Data_Personal\\Software\\chromedriver_win32\\chromedriver.exe"");;
        WebDriver driver = new ChromeDriver();
        driver.get(""http://hireqa.co.in/test/basic_auth.php"");
        // Handling Username alert
        driver.switchTo().alert().sendKeys(""HireQA"");
        driver.switchTo().alert().accept();
        // Handling Password alert
        driver.switchTo().alert().sendKeys(""HireQA"");
        driver.switchTo().alert().accept();
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *