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

后端 未结 8 1893
死守一世寂寞
死守一世寂寞 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:27

    Extending from the correct answer of Andrey-Egorov using .executeScript() to conclude my own question example:

    inputField = driver.findElement(webdriver.By.id('gbqfq'));
    driver.executeScript("arguments[0].setAttribute('value', '" + longstring +"')", inputField);
    
    0 讨论(0)
  • 2020-11-30 04:29

    If you want to use some variable, you may use this way:

    String value= "your value";
    driver.execute_script("document.getElementById('q').value=' "+value+" ' ");
    
    0 讨论(0)
提交回复
热议问题