Skip to content

Commit 68f82b3

Browse files
garg3133AutomatedTesterharsha509
authored
[js]: Fix sendKeys command fail on FileDetector.handleFile error. (#14663)
Fix sendKeys command failing on FileDetector handleFile error. Co-authored-by: David Burns <[email protected]> Co-authored-by: Sri Harsha <[email protected]>
1 parent b2702ca commit 68f82b3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

javascript/node/selenium-webdriver/lib/webdriver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,7 @@ class WebElement {
27522752
keys = await this.driver_.fileDetector_.handleFile(this.driver_, keys.join(''))
27532753
} catch (ex) {
27542754
this.log_.severe('Error trying parse string as a file with file detector; sending keys instead' + ex)
2755+
keys = keys.join('')
27552756
}
27562757

27572758
return this.execute_(

javascript/node/selenium-webdriver/test/lib/webdriver_test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,32 @@ describe('WebDriver', function () {
932932

933933
return driver.findElement(By.id('foo')).sendKeys('original/', 'path')
934934
})
935+
936+
it('sendKeysWithAFileDetector_handlerError', function () {
937+
let executor = new FakeExecutor()
938+
.expect(CName.FIND_ELEMENT, {
939+
using: 'css selector',
940+
value: '*[id="foo"]',
941+
})
942+
.andReturnSuccess(WebElement.buildId('one'))
943+
.expect(CName.SEND_KEYS_TO_ELEMENT, {
944+
id: WebElement.buildId('one'),
945+
text: 'original/path',
946+
value: 'original/path'.split(''),
947+
})
948+
.andReturnSuccess()
949+
.end()
950+
951+
let driver = executor.createDriver()
952+
let handleFile = function (d, path) {
953+
assert.strictEqual(driver, d)
954+
assert.strictEqual(path, 'original/path')
955+
return Promise.reject('unhandled file error')
956+
}
957+
driver.setFileDetector({ handleFile })
958+
959+
return driver.findElement(By.id('foo')).sendKeys('original/', 'path')
960+
})
935961
})
936962

937963
describe('switchTo()', function () {

0 commit comments

Comments
 (0)