Trying to get text using getText() method with Selenium and Javascript but not having luck.
const {Builder, By, Key, until} = require('selenium-webdriver'); (async function example() { let driver = await new Builder().forBrowser('chrome').build(); try { // Navigate to webscraper.io await driver.get('https://webscraper.io/test-sites'); // Scrape links let links = await driver.findElements(By.xpath('//*[@class="row test-site"]/div/h2/a')) // loop through links and print console.log('\nFound ' + links.length + ' Links total.\n') var link; for (link of links) { console.log(link.getText()); }; } finally{ driver.quit(); } })(); Here are the errors i'm getting.
Found 7 Links total. Promise { <pending> } (node:92934) UnhandledPromiseRejectionWarning: Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:62579 at ClientRequest.<anonymous> ''' https://stackoverflow.com/questions/65868010/trying-to-get-text-using-gettext-method-with-selenium-and-javascript January 24, 2021 at 03:20PM
没有评论:
发表评论