Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get text of an HTML-Element with Selenium/Node.js

Unfortunately I did not find any existing solution for my problem on stackoverflow. So, can someone help.

I want to get the text of an html-element. I tried this:

var element = driver.findElement(webdriver.By.className("credits")).getText();

console.log(element);

Unfortunately this did not work so far.

like image 751
Tonisal Avatar asked Dec 10 '22 10:12

Tonisal


1 Answers

Someone posted an answer and deleted it seconds after it...thank you anyway:

For you information, this works fine for me:

var textPromise = driver.findElement(webdriver.By.className("credits")).getText();
textPromise.then((text) => {
  console.log(text);
});
like image 50
Tonisal Avatar answered Dec 22 '22 03:12

Tonisal