Open jeremyjia opened 3 years ago
Python参考代码:
from selenium import webdriver
driver = webdriver.Chrome() driver.maximize_window() driver.get("https://www.baidu.com/") driver.implicitly_wait(100)
lists = driver.get_log('browser') print (lists) driver.close()
Java参考代码:
public void logsTest(){
WebDriver driver = null;
try {
System.setProperty("webdriver.chrome.driver", "resources/chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--incognito"));
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type");
options.addArguments("start-maximized");
options.addArguments("chrome.switches", "--disable-extensions");
capabilities.setCapability("chrome.binary", "resources/chromedriver.exe");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(capabilities);
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
} catch (Exception se) {
Log.logInfo(se.getMessage());
}
driver.get("http://rosewholesale.com.trunk.s1.egomsl.com/index.html");
LogEntries logEntries =driver.manage().logs().get(LogType.BROWSER);
for(LogEntry entry : logEntries) {
System.out.println("chrome.console===="+" "+entry.getLevel() +" "+ entry.getMessage());
}
}
【24】惊悚电影10部《高空7500 (2019)》。。。 沙鸥在路上 2021-10-24 09:48 https://mp.weixin.qq.com/s/VuYWUwH7JKJvwJ5EsuH81Q