Set value of input instead of sendKeys() - Selenium WebDriver nodejs

后端 未结 8 1959
死守一世寂寞
死守一世寂寞 2020-11-30 03:53

I have a long string to test and sendKeys() takes too long. When I tried to set the value of the text the program crashes. I know the Selenium

8条回答
  •  無奈伤痛
    2020-11-30 04:24

    Try to set the element's value using the executeScript method of JavascriptExecutor:

    WebDriver driver = new FirefoxDriver();
    JavascriptExecutor jse = (JavascriptExecutor)driver;
    jse.executeScript("document.getElementById('elementID').setAttribute('value', 'new value for element')");
    

提交回复
热议问题