URGENT -- Not Able to send value on Text box using "SendKey" | Selenium Forum
M
Posted on 26/12/2016
Hi Ashish,
I am trying to enter the value into textbox using but it throw an error :-
[b:2m723h60]Driver Used :- Chrome driver[/b:2m723h60]


[b:2m723h60]Below is the Code for the textbox to send the value :-[/b:2m723h60]

[b:2m723h60][u:2m723h60]type("SatelliteBox_Textbox_xpath", table.get("SatelliteBox"));[/u:2m723h60][/b:2m723h60]


[b:2m723h60]Stack Trace :- [/b:2m723h60]

FAILED: loginCare({DealerName=ForTesting, SatelliteCard=41115593141, Runmode=Y, SurName=Testingg, PinCode=678622, SatelliteBox =410414780151014566, landmark=Delhi, FirstName=Testing, Address1=Abc})
org.openqa.selenium.WebDriverException: unknown error: [b:2m723h60]keys should be a string[/b:2m723h60]
(Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.1.7601 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 34 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'BDTUDV31377', ip: '172.19.70.61', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\Users\TI01266\AppData\Local\Temp\scoped_dir4588_1821}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.87, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 95bb26918377d09036c0b218c27b4a5b
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:122)
at src_Base_BaseTest.BaseTest.type(BaseTest.java:298)
at Src_Test_TestCases.login.loginCare(login.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================

M
Replied on 26/12/2016

have you tried it with Mozilla? can I have the access to website?

you can convert this [color=#FF0000:sywcadum]table.get("SatelliteBox")[/color:sywcadum] into a string first and try again.


M
Replied on 26/12/2016

Yes i tried it on Mozilla too but same issue occur. I observed that when i directly pass the data into (send Key) function its work. i.e.

driver.findElement(By.xpath("//*[@id='txtbeembox1']")).[b:sbkgc8u5]sendKeys("410414780151014566"[/b:sbkgc8u5]); --- Work

But when i fetch this from Excell sheet its not work i.e.
driver.findElement(By.xpath("//*[@id='txtbeembox1']")).[b:sbkgc8u5]sendKeys(table.get("SatelliteBox"))[/b:sbkgc8u5]; --- Nor Work


[b:sbkgc8u5]Convert into String too[/b:sbkgc8u5]:-

driver.findElement(By.xpath("//*[@id='txtbeembox1']")).[b:sbkgc8u5]sendKeys(table.get("SatelliteBox").tostring());
OR
type("SatelliteBox_Textbox_xpath", table.get("SatelliteBox").toString());


[b]Stack Trace :- [/b:sbkgc8u5]

FAILED: loginCare({DealerName=ForTesting, SatelliteCard=41115593141, Runmode=Y, SurName=Testingg, PinCode=678622, SatelliteBox =410414780151014566, landmark=Delhi, FirstName=Testing, Address1=Abc})
java.lang.NullPointerException
at Src_Test_TestCases.login.loginCare(login.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================


please refer attached screen shot too.

Responsive image

M
Replied on 27/12/2016

Plz suggest.


M
Replied on 27/12/2016

have you tried with "Thread.sleep"?


M
Replied on 27/12/2016

the error has been changed.

java.lang.NullPointerException
at Src_Test_TestCases.login.loginCare(login.java:89)


what is at login.java line 89?


M
Replied on 27/12/2016

Yes i used Thread.Sleep but its not work.

@Ashish
I tried it again, at line number 92 -> Code :- type("SatelliteBox_Textbox_xpath",table.get("SatelliteBox").toString());

SatelliteBox_Textbox_xpath ==> xpath of the Text box.
table.get("SatelliteBox") ==> Get the data of "SatelliteBox" columnn from excel sheet.

[b:kp3r5963]NOTE:- [/b:kp3r5963] Please refer the HTML of that control.


[b:kp3r5963]Stack Trace[/b:kp3r5963] :-

FAILED: loginCare({DealerName=ForTesting, SatelliteCard=41115593141, Runmode=Y, SurName=Testingg, PinCode=678622, SatelliteBox =410414780151014566, landmark=Delhi, FirstName=Testing, Address1=Abc})
java.lang.NullPointerException
[b:kp3r5963]at Src_Test_TestCases.login.loginCare(login.java:92)[/b:kp3r5963]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================

Responsive image

M
Replied on 27/12/2016

run this and report


String xyz=table.get("SatelliteBox").toString();
syso(xyz);
type("SatelliteBox_Textbox_xpath", xyz);


M
Replied on 28/12/2016

String xyz=table.get("SatelliteBox").toString();
syso(xyz);
type("SatelliteBox_Textbox_xpath", xyz);

It does nothing, throw same exception. When i Debug it on first line control not move to next line and throw an error.




Stack Trace :-
FAILED: loginCare({DealerName=ForTesting, SatelliteCard=41115593141, Runmode=Y, SurName=Testingg, PinCode=678622, SatelliteBox =410414780151014566, landmark=Delhi, FirstName=Testing, Address1=Abc})
[b:31reritt]java.lang.NullPointerException[/b:31reritt]
at Src_Test_TestCases.login.loginCare(login.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================

Responsive image

M
Replied on 28/12/2016

sam please be mindful of black space.

[color=#FF0000:4o1i7eri]SatelliteBox =410414780151014566[/color:4o1i7eri]


use this, it will work

type("SatelliteBox_Textbox_xpath", table.get("SatelliteBox "));


M
Replied on 29/12/2016

Thanks Ashish,
Its work. Responsive image