The original question says clear () cannot be used. This does not apply to this situation. I am adding my working example here, as this post was one of the first Google results to clear input before entering a value.
For input where there are no additional restrictions, I turn on the browser-independent Selenium method using NodeJS. This snippet is part of a shared library that I import with var test = require( 'common' ); in my test cases. This is for defining the standard module.exports node.
when_id_exists_type : function( id, value ) { driver.wait( webdriver.until.elementLocated( webdriver.By.id( id ) ) , 3000 ) .then( function() { var el = driver.findElement( webdriver.By.id( id ) ); el.click(); el.clear(); el.sendKeys( value ); }); },
Find the item, click on it, clear it and send the keys.
This page provides a complete code example and an article that may help.
Lance Cleveland Sep 27 '17 at 23:00 2017-09-27 23:00
source share