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 Thakur 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 Thakur Replied on 07/10/2020

I cant download chrome version :)

Its not allowing


P
Parshuram Satardekar Replied on 26/10/2020

This giving me same result on the version 86 of chrome, also on edge its responding the same.

looks like there needs some profile settings.

Kindly overlook my upper code there are some spelling mistakes, below is the fuction syntax.

====================================

if (driver =="Chrome") {
//System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "logs\\chrome.logs");
//System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
ChromeOptions options = new ChromeOptions();

options.addArguments("--disable-notifications");
options.addArguments("start-maximized");
options.addArguments("ignore-certificate-errors");
options.addArguments("user-data-dir=C:\\Users\\Laptop\\AppData\\Local\\Google\\Chrome\\User");
wd = new ChromeDriver(options);

}


A
Ashish Thakur Replied on 28/10/2020

Parshuram .. I am unable to replicate this on google

Moreover... google guys are very smart.. they identify automation scripts... :)


P
Parshuram Satardekar Replied on 02/11/2020

Hi Sir,

Are you saying I will not be able to automate this?

Is there any work arround please?

 

Thanks in Advance

Parshuram


P
Parshuram Satardekar Replied on 02/11/2020

Also just just wanted to know if anyone from your students have found this cos its abvious that someone would observe this.

Sir, I would appreciate if you can help me out as I am stuck with this issue and not able to proceed(it happens on Yahoo,Google,FB ect).


P
Parshuram Satardekar Replied on 02/11/2020

I think this is more about browser than a specific brand eg. Google,FB.

Is there anything we can do to about browser profile or any system config?