File tree Expand file tree Collapse file tree
javascript/node/selenium-webdriver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -801,7 +801,13 @@ class Actions {
801801 * @return {!Actions } a self reference.
802802 */
803803 sendKeys ( ...keys ) {
804+ const { WebElement } = require ( './webdriver' )
805+
804806 const actions = [ ]
807+ if ( keys . length > 1 && keys [ 0 ] instanceof WebElement ) {
808+ this . click ( keys [ 0 ] ) ;
809+ keys . shift ( )
810+ }
805811 for ( const key of keys ) {
806812 if ( typeof key === 'string' ) {
807813 for ( const symbol of key ) {
Original file line number Diff line number Diff line change @@ -239,6 +239,21 @@ suite(function (env) {
239239 assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
240240 } )
241241
242+ it ( 'can send keys to designated element' , async function ( ) {
243+ await driver . get ( Pages . formPage )
244+
245+ let el = await driver . findElement ( By . id ( 'email' ) )
246+ assert . strictEqual ( await el . getAttribute ( 'value' ) , '' )
247+
248+ await driver . actions ( ) . sendKeys ( el , 'foobar' ) . perform ( )
249+
250+ await driver . wait (
251+ async ( ) => ( await el . getAttribute ( 'value' ) ) === 'foobar' ,
252+ 10000
253+ )
254+ assert . strictEqual ( await el . getAttribute ( 'value' ) , 'foobar' )
255+ } )
256+
242257 ignore ( env . browsers ( Browser . FIREFOX , Browser . SAFARI ) ) . it (
243258 'can scroll with the wheel input' ,
244259 async function ( ) {
You can’t perform that action at this time.
0 commit comments