Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Grieve
Treehouse Moderator 91,253 PointssendKeys isn't working when using xpath
I am, I'm afraid... on the cusp of giving up on Selenium. I think my system is cursed never to be able to follow along with this course ever again. :)
As of right now this is my project on this URL. a webspace to test selenium and follow along with the course.
https://projects.jonniegrieve.co.uk/selenium/
These are the commands I'm trying to use
const selenium = require("selenium-webdriver");
const driver = new selenium.Builder().forBrowser("chrome").build();
const url="http://url.com";;
driver.get(url);
const By = selenium.By;
const field = driver.findElement(By.xpath("/html/body/div/header/form/input"));
field.sendKeys("Found this element with an explicit XPath");
Which returns the following... the key error I think being WebDriverError: unknown error: call function result missing 'value'
ManagedPromise {
flow_:
ControlFlow {
propagateUnhandledRejections_: true,
activeQueue_:
TaskQueue {
name_: 'TaskQueue::107',
flow_: [Circular],
tasks_: [Array],
interrupts_: null,
pending_: null,
subQ_: null,
state_: 'new',
unhandledRejections_: Set {} },
taskQueues_: Set { [Object] },
shutdownTask_: null,
hold_:
Timeout {
_called: false,
_idleTimeout: 2147483647,
_idlePrev: [Object],
_idleNext: [Object],
_idleStart: 975459,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: 2147483647,
_destroyed: false,
domain: [Object],
[Symbol(asyncId)]: 1401,
[Symbol(triggerAsyncId)]: 6 } },
stack_: { Task: WebElement.sendKeys()
at thenableWebDriverProxy.schedule (C:\xamp\htdocs\selenium\node_modules\sel
enium-webdriver\lib\webdriver.js:807:17)
at WebElementPromise.schedule_ (C:\xamp\htdocs\selenium\node_modules\seleniu
m-webdriver\lib\webdriver.js:2010:25)
at WebElementPromise.sendKeys (C:\xamp\htdocs\selenium\node_modules\selenium
-webdriver\lib\webdriver.js:2174:19)
at repl:1:7
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:240:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:468:10)
at emitOne (events.js:121:20) name: 'Task' },
parent_: null,
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null }
> WebDriverError: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d902
3f),platform=Windows NT 10.0.16299 x86_64)
at Object.checkLegacyResponse (C:\xamp\htdocs\selenium\node_modules\selenium
-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\xamp\htdocs\selenium\node_modules\selenium-webdrive
r\lib\http.js:509:13)
at doSend.then.response (C:\xamp\htdocs\selenium\node_modules\selenium-webdr
iver\lib\http.js:441:30)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
From: Task: WebElement.sendKeys()
at thenableWebDriverProxy.schedule (C:\xamp\htdocs\selenium\node_modules\sel
enium-webdriver\lib\webdriver.js:807:17)
at WebElementPromise.schedule_ (C:\xamp\htdocs\selenium\node_modules\seleniu
m-webdriver\lib\webdriver.js:2010:25)
at WebElementPromise.sendKeys (C:\xamp\htdocs\selenium\node_modules\selenium
-webdriver\lib\webdriver.js:2174:19)
at repl:1:7
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:240:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:468:10)
at emitOne (events.js:121:20)
I'm trying really hard to debug the errors I keep facing to try and get a better understanding of what they occur and how I can stop them. At least the browser isn't ceashing all the time like last time. Would really appreciate ideas if anyone has any :)
2 Answers
Jay McGavren
Treehouse TeacherPer https://stackoverflow.com/questions/49162667/unknown-error-call-function-result-missing-value-for-selenium-send-keys-even , try running npm install -g chromedriver
from a shell prompt. (I did npm uninstall -g chromedriver
first but that probably wasn't necessary.) Not sure whether the rest of the script is working correctly, but that fixed the error, at least.
neilsatterfield
Front End Web Development Techdegree Graduate 18,018 PointsI had the same issue and it took me quite a while to get it to work on Windows 10. It turned out I had an older version of chromedriver.exe in a folder with the PATH set in Environmental Variables. I ended up downloading a newer version and resetting the PATH. I found this video to be helpful: https://www.youtube.com/watch?v=dz59GsdvUF8
Jonathan Grieve
Treehouse Moderator 91,253 PointsThanks for your input Neil :)
So once I'd got round that issue I found my Git Bash would close down all the time after the completed Selenium Tests. It would dump something like this in the error log.
[0411/154733.215:WARNING:crash_report_exception_handler.cc(62)] ProcessSnapshotWin::Initialize failed
[0417/114832.569:ERROR:process_reader_win.cc(123)] NtOpenThread: {Access Denied} A process has requested access to an object, but has not been granted those access rights. (0xc0000022)
[0417/114832.581:ERROR:exception_snapshot_win.cc(88)] thread ID 10760 not found in proces
Now ideally this shouldn't be happening at all.
From what I've gathered from extensive research (and there's not much out there to be honest, it's down to something called an Interprocess Communication Problem. Something to do with an instance of Git Bash not cooperating with the inner workings of Selenium Web Driver.
There was no fix I could find and noone ever responded to any of my forum requests in the Selenium Forum.
And then it occurred to me I was following along the Selenium Course in every way except one. I wasn't following the course with the integrated terminal in Visual Studio Code. I did that, and the tests worked perfectly.
I haven't even had any answers about that, but as long as it works it is okay by me. :)
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsThere must be a hardware issue behind all of this. I know that Selenium is picking up the xpath properly and selecting the field but after trying this I'm getting the same error I'm afraid.
One thing I did notice however was that although my chromedriver version is 2.37.... I found this in in the output from the shell prompt
It seems to be trying to find the chromedriver 2.33 whereas chromedriver comes up as 2.37 when using the --version subcommand
Is it possible it's trying to do all of this with an outdated driver?
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsHi Jay,
Thanks so much for replying to this topic. It kicked me into action and it looks like I've solved the issue with sendKeys.
The driver info error seemed to be causing Selenium to think it was still running from chromedriver v33 Somehow, so I deleted that file, and after uninstalling and installing a few times and moving the odd file here and there, sendkeys is working. :D
Thanks again!
Jay McGavren
Treehouse TeacherJay McGavren
Treehouse Teacher@johnathangrieve Maybe that
npm uninstall -g chromedriver
I did first wasn't optional, then. I probably would have encountered the same issue you did if I hadn't done that.Glad you got it working!