Block the Foresee feedback popup during Selenium Test Exection

If your AUT has this new “Foresee feedback” popup enabled, you will see that scripts will fail whenever it appears randomly.

In order to tackle this issue, you can follow the below idea.

 

  1. Download the popper blocker extension crx file from google and save it in your system
  2. Setup the chrome options to invoke this extension
  3. add this to the desired capabilities
  4. invoke the new driver instance with this capability

But when you invoke the browser, you will see that the popperblocker gets invoked in new tab and not in the original tab. Hence you need to close the first (original) tab and point to the new tab where the extension is enabled

 

Full code below:


//invoke popup blocker extension for every instance of driver
ChromeOptions op = new ChromeOptions();
op.addExtensions(new File("C:\\Users\\I366155\\Downloads\\bkkbcggnhapdmkeljlodobbkopceiche-4.0.6-Crx4Chrome.com.crx"));

//setup this capability profile
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, op);

//add this profile to new instance of driver
driver = new ChromeDriver(capabilities);

//original tab will not have pop up blocker enabled. Close that and switch to new tab where it is enabled.
String originalHandle = driver.getWindowHandle();
System.out.println(driver.getCurrentUrl());
ArrayList<String> availableWindows = new ArrayList<String>(driver.getWindowHandles());

if(driver.getWindowHandles().size()>1){
for(String handle : driver.getWindowHandles()) {
if (handle.equals(originalHandle)) {
driver.switchTo().window(handle);
driver.close();
driver.switchTo().window(availableWindows.get(1));
}
}
}