I followed the solution given by @obiwankoban and @SubjectiveReality mentioned at the following link: How to handle authentication popup in Chrome with Selenium WebDriver using Java
I performed the below steps:
- Created a folder called 'Extension'
Created following two files inside Extension folder. manifest.json
{ "name": "Webrequest API", "version": "1.0", "description": "Extension to handle Authentication window", "permissions": [ "webRequest", "webRequestBlocking", "" ], "background": { "scripts": [ "webrequest.js" ] }, "manifest_version": 2 }
webrequest.js
chrome.webRequest.onAuthRequired.addListener(function(details){
console.log("chrome.webRequest.onAuthRequired event has fired");
return {
authCredentials: {username: "getestone", password: "Viacom@2020"}
};
},
{urls:["<all_urls>"]},
['blocking']);
- Updated Pack extension on chrome browser, post which .crx file gets created.
- My Selenium code is as follows:
Selenium code
public class openWebsite {
public static void main(String[] args) {
Properties prop = new Properties();
ChromeOptions options = new ChromeOptions();
File addonpath = new
File("C:\\Users\\10642575\\Desktop\\Work\\Automation\\AuthPopUp\\Extension.crx");
ChromeOptions chrome = new ChromeOptions();
chrome.addExtensions(addonpath);
//options.addArguments("--no-sandbox");
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\10642575\\Desktop\\Work\\Automation\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS) ;
driver.get("https://uat.contentplatform.viacom.com/");
driver.findElement(By.xpath("//input[@type='email']")).sendKeys("getest.one@viacom.com");
driver.findElement(By.xpath("//input[@type='submit']")).click();
}
}
On following the above steps, I still get the server authentication pop up when the website is launched on chrome. Authentication bypass is not working.
PLZ HELP