How to handle a consent form that has I Agree button on google and yahoo websites. | Selenium Forum
P
Parshuram Satardekar Posted on 17/09/2020

package GoogleSearch;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.Test;

import BaseTest.BrowserSetup;
import io.grpc.Context.Key;

public class GoogleSearch extends BrowserSetup {

@Test
public void SearchName() throws InterruptedException {
String browser ="Chrome";
WebDriver wd = DriverSetup(browser);
wd.get("http://google.com");
Thread.sleep(5000);

wd.findElement(By.xpath("//span[text()='I agree']")).click();

//wd.findElement(By.xpath("//div[@id='introAgreeButton']")).sendKeys(Keys.ENTER);;

wd.findElement(By.name("q")).sendKeys("Parshuram Satardekar");
wd.findElement(By.name("btnK")).click();


}

}


A
Ashish Replied on 22/09/2020

You need to use Chrome/Firefox with a profile in this case.

The video can be found under Scripting in Different Browsers --> Part 2 (Profiling in Browsers)


P
Parshuram Satardekar Replied on 24/09/2020

Hi Sir, Thank you for your reply.I have already placed profiles in my code as below in DriverSetup, still facing the issue.

 

public WebDriver DriverSetup(String driver) {

WebDriver wd =null;
if (driver =="Chrome") {

System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--diable-notifications");
ops.addArguments("--start-maximized");
ops.addArguments("--use-fake-ui-for-media-stream");
ops.addArguments("--disable-user-media-security=true");
wd = new ChromeDriver(ops);
}
else if (driver=="Mozila") {

System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "logs\\firefox.logs");
FirefoxOptions optn = new FirefoxOptions();
FirefoxProfile prof = new FirefoxProfile();
prof.setPreference("dom.webnotifications.enable", false);
optn.setProfile(prof);
wd =new FirefoxDriver(optn);

}
else if (driver== "Edge") {
EdgeOptions optn = new EdgeOptions();
optn.addArguments("--disable-notification");
optn.addArguments("--start-maximized");
wd = new EdgeDriver(optn);
}
return wd;
}


P
Parshuram Satardekar Replied on 25/09/2020

Screen Shot added for the consent form, kindly advise.


Related Posts