I need to get text of the element in an image but that element is not displaying on a web page.
Asked
Active
Viewed 645 times
-3
-
3The question doesn't appear to include any attempt at all to solve the problem. Please edit the question to show what you've tried, and show a specific roadblock you're running into with [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). For more information, please see [How to Ask](https://stackoverflow.com/help/how-to-ask). – Andreas Feb 14 '20 at 06:23
2 Answers
0
You can try something like this, and give id to your element
JavascriptExecutor executor = (JavascriptExecutor)driver;
String text= executor.executeScript("document.getElementById('someID').innerHTML");
as earlier @Andreas mention be more descriptive. Good luck. Hope it helps

Solijon Sharipov
- 179
- 7
0
You can try with JS. It is not depends on what is element state either it is visible or not
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement element=driver.findElement(By.xpath("//div[@class='_3716Tfxt']"));
String text = (String) js.executeScript(“return arguments[0].text;”, element);

Muzzamil
- 2,823
- 2
- 11
- 23