Discussion:
[selenium-users] alert.sendKeys with Chrome is not working
Payam Fard
2018-12-01 02:51:55 UTC
Permalink
Hi,

Here is the code snippet I have:

Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");

It works perfectly fine in Firefox, but in Chrome does not work. I am using Gecko
driver version 0.23.0, Chrome driver version 2.43.0.

Any help would be appreciated.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5932201f-3684-4777-9138-16f7f66a091d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
connect2tech
2018-12-01 18:39:43 UTC
Permalink
Fix is not ready yet. Marked it as Available incase if anyone wants to work on this before we can get to it.

Also, please note - Sending text to the prompt dialog functions properly. Its just that text is not visible when chromedriver types into the prompt. But if you try to fetch the text from prompt, then it retrieves correctly.

which means, it does not block any test from executing.

driver.get("file:///path/to/htmlfile");
Alert alert = driver.switchTo().alert();
alert.sendKeys("testing"); ==> Here, typing is not visible
alert.accept();
System.out.println(alert.getText()); ==> Here, the entered text is correctly fetched

It is an issue at the devtools side.
Since the functionality is not broken & does not block any test, i am decresing the priority of the bug.



You can read more from here.

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120
Post by Payam Fard
Hi,
Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");
It works perfectly fine in Firefox, but in Chrome does not work. I am
using Gecko driver version 0.23.0, Chrome driver version 2.43.0.
Any help would be appreciated.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c94ab217-7a4a-4e95-9acc-31574170ef56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Payam Fard
2018-12-01 18:50:57 UTC
Permalink
Thanks for your reply, but System.out.println(alert.getText()); is not printing the text send to the input box. It is printing the label right before the input box. If you go to https://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt and click on "Try it" button, alert.getText() prints out "Please enter your name:". I am looking for the text that is sent to the input box. Would you please elaborate on why this is not a blocker for any tests? I need to write into the input box, but I am not able to. Appreciate your response.
Post by connect2tech
Fix is not ready yet. Marked it as Available incase if anyone wants to work on this before we can get to it.
Also, please note - Sending text to the prompt dialog functions properly. Its just that text is not visible when chromedriver types into the prompt. But if you try to fetch the text from prompt, then it retrieves correctly.
which means, it does not block any test from executing.
driver.get("file:///path/to/htmlfile");
Alert alert = driver.switchTo().alert();
alert.sendKeys("testing"); ==> Here, typing is not visible
alert.accept();
System.out.println(alert.getText()); ==> Here, the entered text is correctly fetched
It is an issue at the devtools side.
Since the functionality is not broken & does not block any test, i am decresing the priority of the bug.
You can read more from here.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120
Post by Payam Fard
Hi,
Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");
It works perfectly fine in Firefox, but in Chrome does not work. I am
using Gecko driver version 0.23.0, Chrome driver version 2.43.0.
Any help would be appreciated.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/831d29f0-bca9-45fe-92f1-e813d58c9f6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
connect2tech
2018-12-01 18:57:40 UTC
Permalink
Alert alert = driver.switchTo().alert();
alert.sendKeys("Selenium");
alert.accept();
System.out.println(alert.getText());

Try this. It will solve your problem, but there will be some issue in line
4. You can handle it with exception handling.

Regards,
~NC
https://goo.gl/DEYjrg
Post by Payam Fard
Thanks for your reply, but System.out.println(alert.getText()); is not printing the text send to the input box. It is printing the label right before the input box. If you go to https://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt and click on "Try it" button, alert.getText() prints out "Please enter your name:". I am looking for the text that is sent to the input box. Would you please elaborate on why this is not a blocker for any tests? I need to write into the input box, but I am not able to. Appreciate your response.
Post by connect2tech
Fix is not ready yet. Marked it as Available incase if anyone wants to work on this before we can get to it.
Also, please note - Sending text to the prompt dialog functions properly. Its just that text is not visible when chromedriver types into the prompt. But if you try to fetch the text from prompt, then it retrieves correctly.
which means, it does not block any test from executing.
driver.get("file:///path/to/htmlfile");
Alert alert = driver.switchTo().alert();
alert.sendKeys("testing"); ==> Here, typing is not visible
alert.accept();
System.out.println(alert.getText()); ==> Here, the entered text is correctly fetched
It is an issue at the devtools side.
Since the functionality is not broken & does not block any test, i am decresing the priority of the bug.
You can read more from here.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120
Post by Payam Fard
Hi,
Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");
It works perfectly fine in Firefox, but in Chrome does not work. I am
using Gecko driver version 0.23.0, Chrome driver version 2.43.0.
Any help would be appreciated.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8b43a59d-2091-4876-bbe4-f68d1e2af968%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Payam Fard
2018-12-01 19:15:06 UTC
Permalink
I am sorry, but I am not sure what I am missing here. I tried the following:

Alert promptAlert = driver.switchTo().alert();
promptAlert.sendKeys("Accepting the alert");
promptAlert.accept();
String msg = "";
try {
msg = promptAlert.getText();
}
catch(Exception nae) {
}
System.out.println("message is " + msg);

msg is an empty string so with Chrome, it is not reading anything into the
msg. I appreciate if you could let me know what I am missing here.
Post by connect2tech
Alert alert = driver.switchTo().alert();
alert.sendKeys("Selenium");
alert.accept();
System.out.println(alert.getText());
Try this. It will solve your problem, but there will be some issue in line
4. You can handle it with exception handling.
Regards,
~NC
https://goo.gl/DEYjrg
Post by Payam Fard
Thanks for your reply, but System.out.println(alert.getText()); is not printing the text send to the input box. It is printing the label right before the input box. If you go to https://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt and click on "Try it" button, alert.getText() prints out "Please enter your name:". I am looking for the text that is sent to the input box. Would you please elaborate on why this is not a blocker for any tests? I need to write into the input box, but I am not able to. Appreciate your response.
Post by connect2tech
Fix is not ready yet. Marked it as Available incase if anyone wants to work on this before we can get to it.
Also, please note - Sending text to the prompt dialog functions properly. Its just that text is not visible when chromedriver types into the prompt. But if you try to fetch the text from prompt, then it retrieves correctly.
which means, it does not block any test from executing.
driver.get("file:///path/to/htmlfile");
Alert alert = driver.switchTo().alert();
alert.sendKeys("testing"); ==> Here, typing is not visible
alert.accept();
System.out.println(alert.getText()); ==> Here, the entered text is correctly fetched
It is an issue at the devtools side.
Since the functionality is not broken & does not block any test, i am decresing the priority of the bug.
You can read more from here.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120
Post by Payam Fard
Hi,
Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");
It works perfectly fine in Firefox, but in Chrome does not work. I am
using Gecko driver version 0.23.0, Chrome driver version 2.43.0.
Any help would be appreciated.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/93ed1e5d-6bdb-42a5-9282-f414d5d38ff5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
connect2tech
2018-12-01 19:25:32 UTC
Permalink
After you do

promptAlert.accept()

The text will be painted on browser. Then you can get text from browser by
using some locator strategy. No need for the last getText method.
Post by Payam Fard
Alert promptAlert = driver.switchTo().alert();
promptAlert.sendKeys("Accepting the alert");
promptAlert.accept();
String msg = "";
try {
msg = promptAlert.getText();
}
catch(Exception nae) {
}
System.out.println("message is " + msg);
msg is an empty string so with Chrome, it is not reading anything into the
msg. I appreciate if you could let me know what I am missing here.
Post by connect2tech
Alert alert = driver.switchTo().alert();
alert.sendKeys("Selenium");
alert.accept();
System.out.println(alert.getText());
Try this. It will solve your problem, but there will be some issue in
line 4. You can handle it with exception handling.
Regards,
~NC
https://goo.gl/DEYjrg
Post by Payam Fard
Thanks for your reply, but System.out.println(alert.getText()); is not printing the text send to the input box. It is printing the label right before the input box. If you go to https://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt and click on "Try it" button, alert.getText() prints out "Please enter your name:". I am looking for the text that is sent to the input box. Would you please elaborate on why this is not a blocker for any tests? I need to write into the input box, but I am not able to. Appreciate your response.
Post by connect2tech
Fix is not ready yet. Marked it as Available incase if anyone wants to work on this before we can get to it.
Also, please note - Sending text to the prompt dialog functions properly. Its just that text is not visible when chromedriver types into the prompt. But if you try to fetch the text from prompt, then it retrieves correctly.
which means, it does not block any test from executing.
driver.get("file:///path/to/htmlfile");
Alert alert = driver.switchTo().alert();
alert.sendKeys("testing"); ==> Here, typing is not visible
alert.accept();
System.out.println(alert.getText()); ==> Here, the entered text is correctly fetched
It is an issue at the devtools side.
Since the functionality is not broken & does not block any test, i am decresing the priority of the bug.
You can read more from here.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120
Post by Payam Fard
Hi,
Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");
It works perfectly fine in Firefox, but in Chrome does not work. I am
using Gecko driver version 0.23.0, Chrome driver version 2.43.0.
Any help would be appreciated.
--
You received this message because you are subscribed to a topic in the
Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/selenium-users/TvVSHN0uJGI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/selenium-users/93ed1e5d-6bdb-42a5-9282-f414d5d38ff5%40googlegroups.com
<https://groups.google.com/d/msgid/selenium-users/93ed1e5d-6bdb-42a5-9282-f414d5d38ff5%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAGoraXHXEsWYG%3DvsZ5_mVo2QLORf0aDuOkesNWwH2Xyki_8dOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Payam Fard
2018-12-01 23:42:57 UTC
Permalink
Thanks much for your help.
Post by connect2tech
After you do
promptAlert.accept()
The text will be painted on browser. Then you can get text from browser
by using some locator strategy. No need for the last getText method.
Post by Payam Fard
Alert promptAlert = driver.switchTo().alert();
promptAlert.sendKeys("Accepting the alert");
promptAlert.accept();
String msg = "";
try {
msg = promptAlert.getText();
}
catch(Exception nae) {
}
System.out.println("message is " + msg);
msg is an empty string so with Chrome, it is not reading anything into
the msg. I appreciate if you could let me know what I am missing here.
Post by connect2tech
Alert alert = driver.switchTo().alert();
alert.sendKeys("Selenium");
alert.accept();
System.out.println(alert.getText());
Try this. It will solve your problem, but there will be some issue in
line 4. You can handle it with exception handling.
Regards,
~NC
https://goo.gl/DEYjrg
Post by Payam Fard
Thanks for your reply, but System.out.println(alert.getText()); is not printing the text send to the input box. It is printing the label right before the input box. If you go to https://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt and click on "Try it" button, alert.getText() prints out "Please enter your name:". I am looking for the text that is sent to the input box. Would you please elaborate on why this is not a blocker for any tests? I need to write into the input box, but I am not able to. Appreciate your response.
Post by connect2tech
Fix is not ready yet. Marked it as Available incase if anyone wants to work on this before we can get to it.
Also, please note - Sending text to the prompt dialog functions properly. Its just that text is not visible when chromedriver types into the prompt. But if you try to fetch the text from prompt, then it retrieves correctly.
which means, it does not block any test from executing.
driver.get("file:///path/to/htmlfile");
Alert alert = driver.switchTo().alert();
alert.sendKeys("testing"); ==> Here, typing is not visible
alert.accept();
System.out.println(alert.getText()); ==> Here, the entered text is correctly fetched
It is an issue at the devtools side.
Since the functionality is not broken & does not block any test, i am decresing the priority of the bug.
You can read more from here.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1120
Post by Payam Fard
Hi,
Alert promptAlert = driver.switchTo().alert();
Thread.sleep(4000);
promptAlert.sendKeys("Accepting the alert");
It works perfectly fine in Firefox, but in Chrome does not work. I am
using Gecko driver version 0.23.0, Chrome driver version 2.43.0.
Any help would be appreciated.
--
You received this message because you are subscribed to a topic in the
Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/selenium-users/TvVSHN0uJGI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/selenium-users/93ed1e5d-6bdb-42a5-9282-f414d5d38ff5%40googlegroups.com
<https://groups.google.com/d/msgid/selenium-users/93ed1e5d-6bdb-42a5-9282-f414d5d38ff5%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/62efdf27-48f7-4496-bc81-954053503e7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...