I read document Selenium and try to code as document. I run code, it open browsers chrome ok. But it has problem, I don't know where it appears the console.log statement?. Because I search on f12 Console tab in Chrome or Visual Studio Code does not appear console.log. Help me!
Thank you everyone
Browser Google Chrome: Version 97.0.4692.71 and ChromeDriver 98.0.4758.48
I installed some library in project
chromedriver: "^97.0.0" selenium-webdriver: "^4.1.1"
This is my code:
const { Builder, By } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
require("chromedriver");
async function DisplayListElement() {
let options = new chrome.Options();
let driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(options)
.build();
try {
// Navigate to Url
await driver.get("https://www.example.com");
// Get all the elements available with tag 'p'
let elements = await driver.findElements(By.css("p"));
for (let e of elements) {
console.log(await e.getText());
}
} finally {
await driver.quit();
}
}
DisplayListElement();
It was some problem when was running as follow:
[7476:8716:0117/152805.277:ERROR:chrome_browser_main_extra_parts_metrics.cc(227)] START: ReportBluetoothAvailability(). If you don't see the END: message, this is crbug.com/1216328.
[7476:8716:0117/152805.310:ERROR:chrome_browser_main_extra_parts_metrics.cc(230)] END: ReportBluetoothAvailability()
[7476:8716:0117/152805.316:ERROR:chrome_browser_main_extra_parts_metrics.cc(235)] START: GetDefaultBrowser(). If you don't see the END: message, this is crbug.com/1216328.
[7476:9600:0117/152805.335:ERROR:device_event_log_impl.cc(214)] [15:28:05.335] USB: usb_device_handle_win.cc:1050 Failed to read descriptor from node connection: A device attached toce attached to not functioning. (0x1F)
[7476:9600:0117/152805.335:ERROR:device_event_log_impl.cc(214)] [15:28:05.335] USB: usb_device_handle_win.cc:1050 Failed to read descr ce attached toiptor from node connection: A devievice_event_log_impl.cc(214)] [15:28:05.566] USB: usb_device_handle_win.cc:1050 Failed to read descriptor from node connection: A devi[7476:9600:0117/152805.335:ERROR:device_event_log_impl.cc(214)] [15:28:05.335] USB: usb_device_handle_win.cc:1050 Failed to read descr117/152805.566:ERROR:device_event_log_impl.cc(214)] [15:28:05.566] USB: usb_device_handle_win.cc:1050 Failed to read descr. (0x1F)
[7476:9600:0117/152805.566:ERROR:device_event_log_impl.cc(214)] [15:28:05.566] USB: usb_device_handle_win.cc:1050 Failed to read descriptor from node connection: A device attached toonnection: A device attached to the system is not functioning. (0x1F)
[7476:8716:0117/152805.687:ERROR:chrome_browser_main_extra_parts_metrics.cc(239)] END: GetDefaultBrowser()