硒-我无法在对话框“继续之前"中单击按钮.在谷歌 [英] Selenium - I can't click button in dialog "Before you continue" in google
本文介绍了硒-我无法在对话框“继续之前"中单击按钮.在谷歌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题,请点击Google对话框中的按钮.这是我的代码:
I have a problem , click button in dialog forms in google. This is my code :
@BeforeEach
public void startDriver() throws InterruptedException {
// Start Chrome browser
System.setProperty("webdriver.chrome.driver", "C:\\gecko\\chrome\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://www.google.pl/?gws_rd=ssl");
}
@Test
@DisplayName("Test strony google")
public void testGoogle() throws InterruptedException, IOException {
System.out.println("Rozpoczecie testu strony google");
ModelStatistic modelStatistic = new ModelStatistic();
System.out.println(modelStatistic.getTimestamp());
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Thread.sleep(4000);
WebElement agree = driver.findElement(By.id("introAgreeButton"));
agree.click();
Thread.sleep(3000);
WebElement name = driver.findElement(By.cssSelector("input[name='q']"));
name.sendKeys("Kamil Surma");
}
Selenium Cant看到Webelement同意.
Selenium Cant's see Webelement agree.
推荐答案
添加以下内容: driver.switchTo().frame(0);
在此之前: WebElement同意= driver.findElement(By.id("introAgreeButton")));
该按钮位于iframe中,驱动程序找不到它.
The button is in iframe and driver can't find it.
这篇关于硒-我无法在对话框“继续之前"中单击按钮.在谷歌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文