Input value returns empty string on JS log
up vote
0
down vote
favorite
I am trying to do a simple webpage interaction from an android app with JavaScript. Here is the problem: I could fill the text input place with changing value of the corresponding text input field with JavaScript. However, when I click the button (which should evaluate the information from the text input field), the value of the text input field appears as an empty string.
Any kind of user interaction(eg. putting a space to the end of the string and deleting it) turns everything to normal. However, since I am trying to automate the whole process, it is not an option.
The code I am using for filling the text input field is very similar to this code:
String username = "cristian";
webview.loadUrl("javascript:document.getElementById('username').value = '"+username+"';");
And the way I call it:
webView.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if(consoleMessage.message().contains("DEPRECATED")){
tester.setValueForItemWithId("comp-jo5fnli5input", loginInfo);
tester.clickOnItemWithClassName("b4label", 0);
}
if(consoleMessage.message().contains("User is logged in")) {
Toast.makeText(getBaseContext(), consoleMessage.message(), Toast.LENGTH_LONG).show();
}
return true;
}
});
I don't think immediate clicking of the button is causing the problem, because I tried to pressing the button manually too and got the same result.
I am waiting for your answers. Please point out if some part of the question is hard to understand.
Have a nice day.
javascript
add a comment |
up vote
0
down vote
favorite
I am trying to do a simple webpage interaction from an android app with JavaScript. Here is the problem: I could fill the text input place with changing value of the corresponding text input field with JavaScript. However, when I click the button (which should evaluate the information from the text input field), the value of the text input field appears as an empty string.
Any kind of user interaction(eg. putting a space to the end of the string and deleting it) turns everything to normal. However, since I am trying to automate the whole process, it is not an option.
The code I am using for filling the text input field is very similar to this code:
String username = "cristian";
webview.loadUrl("javascript:document.getElementById('username').value = '"+username+"';");
And the way I call it:
webView.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if(consoleMessage.message().contains("DEPRECATED")){
tester.setValueForItemWithId("comp-jo5fnli5input", loginInfo);
tester.clickOnItemWithClassName("b4label", 0);
}
if(consoleMessage.message().contains("User is logged in")) {
Toast.makeText(getBaseContext(), consoleMessage.message(), Toast.LENGTH_LONG).show();
}
return true;
}
});
I don't think immediate clicking of the button is causing the problem, because I tried to pressing the button manually too and got the same result.
I am waiting for your answers. Please point out if some part of the question is hard to understand.
Have a nice day.
javascript
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to do a simple webpage interaction from an android app with JavaScript. Here is the problem: I could fill the text input place with changing value of the corresponding text input field with JavaScript. However, when I click the button (which should evaluate the information from the text input field), the value of the text input field appears as an empty string.
Any kind of user interaction(eg. putting a space to the end of the string and deleting it) turns everything to normal. However, since I am trying to automate the whole process, it is not an option.
The code I am using for filling the text input field is very similar to this code:
String username = "cristian";
webview.loadUrl("javascript:document.getElementById('username').value = '"+username+"';");
And the way I call it:
webView.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if(consoleMessage.message().contains("DEPRECATED")){
tester.setValueForItemWithId("comp-jo5fnli5input", loginInfo);
tester.clickOnItemWithClassName("b4label", 0);
}
if(consoleMessage.message().contains("User is logged in")) {
Toast.makeText(getBaseContext(), consoleMessage.message(), Toast.LENGTH_LONG).show();
}
return true;
}
});
I don't think immediate clicking of the button is causing the problem, because I tried to pressing the button manually too and got the same result.
I am waiting for your answers. Please point out if some part of the question is hard to understand.
Have a nice day.
javascript
I am trying to do a simple webpage interaction from an android app with JavaScript. Here is the problem: I could fill the text input place with changing value of the corresponding text input field with JavaScript. However, when I click the button (which should evaluate the information from the text input field), the value of the text input field appears as an empty string.
Any kind of user interaction(eg. putting a space to the end of the string and deleting it) turns everything to normal. However, since I am trying to automate the whole process, it is not an option.
The code I am using for filling the text input field is very similar to this code:
String username = "cristian";
webview.loadUrl("javascript:document.getElementById('username').value = '"+username+"';");
And the way I call it:
webView.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
if(consoleMessage.message().contains("DEPRECATED")){
tester.setValueForItemWithId("comp-jo5fnli5input", loginInfo);
tester.clickOnItemWithClassName("b4label", 0);
}
if(consoleMessage.message().contains("User is logged in")) {
Toast.makeText(getBaseContext(), consoleMessage.message(), Toast.LENGTH_LONG).show();
}
return true;
}
});
I don't think immediate clicking of the button is causing the problem, because I tried to pressing the button manually too and got the same result.
I am waiting for your answers. Please point out if some part of the question is hard to understand.
Have a nice day.
javascript
javascript
edited Nov 7 at 17:45
Bob Arnson
17.7k22936
17.7k22936
asked Nov 7 at 7:56
Furkan Küçük
469
469
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53185425%2finput-value-returns-empty-string-on-js-log%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password