3
Node.js에서 Selenium Webdriver Chrome을 사용하여 웹 페이지로 이동하고 입력 내용을 입력하고 버튼을 클릭 한 다음 브라우저 콘솔의 내용을 가져와야합니다. 웹 페이지를 가져 와서 입력 내용을 채우고 버튼을 클릭 할 수 있지만 지금까지는 콘솔의 내용을 검색하는 방법을 알 수 없습니다. 어떻게해야합니까? documentation 당Node.js에서 Selenium Webdriver Chrome을 사용하여 콘솔 읽기.
const webdriver = require('selenium-webdriver');
const chromeDriver = require('selenium-webdriver/chrome');
const path = require('chromeDriver').path;
const service = new chromeDriver.ServiceBuilder(path).build();
chromeDriver.setDefaultService(service);
const { By, until } = webdriver;
webdriver.promise.USE_PROMISE_MANAGER = false;
const CHROME_BIN_PATH = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome';
const options = new chromeDriver.Options();
options.setChromeBinaryPath(CHROME_BIN_PATH);
options.addArguments(
'headless',
'disable-gpu',
);
const main = async() => {
try{
const driver = await new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.forBrowser('chrome')
.setChromeOptions(options)
.build();
await driver.get('http://example.com/some/path.html');
await driver.findElement(By.name('name2')).sendKeys('webdriver');
await driver.findElement(By.name('button2')).click();
const title = await driver.findElement(By.css('title')).getAttribute('innerHTML');
console.log({ title });
const log = GET THE BROWSER'S CONSOLE LOG
console.log(log);
await driver.quit();
} catch (error) {
console.log(error);
}
};
main();
링크 주셔서 감사합니다
이
내가 지금까지 가지고있는 코드입니다! 나는 오후를 문서를 읽는 데 보냈지 만 그 페이지를 찾지 못했습니다. 이제 로그 아웃 → 셀레늄 - webdriver/lib/logging (http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index.html)을보고있을 때 로깅과 selenium-webdriver/lib/logging 링크가 모두 같은 장소로 갔다고 가정하고 (단지 그렇지 않습니다) 오직 로깅 링크 만 클릭했습니다. 어쨌든, 그게 정확히 내가 찾고 있던 문서입니다! – irrational