Not able to find element 'I Agree' button on google consent form, please refer the code and attached screen shot. | Selenium Forum
P
Parshuram Satardekar Posted on 30/09/2020

 

package GoogleSearch;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
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);  //calling deriver setup methode to set profile

wd.get("http://google.com");
Thread.sleep(10000);

//Not able to find below 'I Agree' element on the consent form 
WebElement bnt = wd.findElement(By.xpath("//div[@id='introAgreeButton']/span/span[text()='I agree']"));
bnt.sendKeys("Enter");

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

}

}

 

 

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;
}


A
Ashish Replied on 04/10/2020

I dont see the I agree button on google.com

I am not sure


P
Parshuram Satardekar Replied on 05/10/2020

@Ashish, is this because of Chrome Version 73.0.3683.103.

can you check on the same version ?


A
Ashish Replied on 07/10/2020

I cant download chrome version :)

Its not allowing