I am facing an issue where I am trying to retrieve the value from a WebElement 'input'. The general method getText() doesn't seem to work for me in this case. However, when I tried using JavaScript in the console, it worked perfectly:
"document.evaluate('(//div[@id="CreateOrderBlock"]//input[@class="el-input__inner"])[3]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value;"
Now, I am wondering how do I handle this in a test scenario using Selenium WebDriver with Java. How can I convert it to an integer in Java? Perhaps I need to use JavascriptExecutor, but I would appreciate an example either way. I attempted to do the following:
String summValueString = (String)((JavascriptExecutor) driver).executeScript("document.evaluate('(//div[@id='CreateOrderBlock']//input[@class='el-input__inner'])[3]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value;");
<div class="input el-input">
<!---->
<input autocomplete="off" type="text" rows="2" validateevent="true" class="el-input__inner">
<!---->
<!---->
<!---->
</div>
Thank you for your assistance.