Last active
May 16, 2019 10:35
-
-
Save sleepless-se/1b3e868ad79ebbec2960632ac6b55260 to your computer and use it in GitHub Desktop.
inputTextByJavascriptExcuter in java for selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import | |
import org.openqa.selenium.JavascriptExecutor; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
/** | |
* @param xpath | |
* Please select text box element | |
* @param text | |
* Please set your text | |
* @param driver | |
* Please set your WebDriver | |
*/ | |
public void inputTextByJSE(String xpath, String text,WebDriver driver) { | |
JavascriptExecutor jse = (JavascriptExecutor) driver; | |
WebElement elm = driver.findElement(By.xpath(xpath)); | |
String script = "arguments[0].value='" + text + "';"; | |
jse.executeScript(script, elm); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment