I’m trying to use Selenium to get text elements from websites using Node.
As an example, I am using the URL: https://www.ebuyer.com/874785-exdisplay-gigabyte-geforce-rtx-2080-ti-gaming-oc-11gb-graphics-card-ebr2-gv-n208tgaming-oc-11gc and the XPath /html/body/section/div[1]/div[3]/div[1]/div[3]/form/button
I can see in an XPaath selector plugin that it results in "Add to Basket", however the below code logs a blank string. Any idea what I’m doing wrong
const selenium = require('selenium-webdriver'); const chrome = require('selenium-webdriver/chrome'); const chromedriver = require('chromedriver'); chrome.setDefaultService(new chrome.ServiceBuilder(chromedriver.path).build()); const driver = new selenium.Builder() .withCapabilities(selenium.Capabilities.chrome()) .build(); await driver.get(url); await delay(1000); const value = await driver.findElement(web.By.xpath(xPath)).getText(); console.log(value)