最近在搞自动填问卷的代码,因为工作需要。我需要填写的那个问卷谷歌浏览器显示不完整,而360可以完整显示(360也是用得谷歌的内核,只是版本不一样)。我使用java+selenium登录网址,360浏览器登陆正常但是定位元素出现错误 ,报错:no such window: target window already closed。用谷歌浏览器就能完成定位元素自动填写。不知道是什么原因?
代码片段如下:
使用360的驱动:
System.setProperty("webdriver.chrome.driver", "D:\\\\chromedriver_win32\\chromedriver360\\chromedriver.exe");
Thread.sleep(100);
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Users\\Administrator\\AppData\\Roaming\\secoresdk\\360se6\\Application\\360se.exe");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://org.acfic.org.cn/openplatform/dist/pc/index.html#/login");
Thread.sleep(100);
List<WebElement> ele =driver.findElements(By.tagName("img"));
运行效果:
使用谷歌的驱动:
System.setProperty("webdriver.chrome.driver", "D:\\\\chromedriver_win32\\chromedriver谷歌\\chromedriver.exe");
Thread.sleep(100);
ChromeOptions options = new ChromeOptions();
//options.setBinary("C:\\Users\\Administrator\\AppData\\Roaming\\secoresdk\\360se6\\Application\\360se.exe");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://org.acfic.org.cn/openplatform/dist/pc/index.html#/login");
Thread.sleep(100);
List<WebElement> ele =driver.findElements(By.tagName("img"));
运行效果: