PressKeys() in Android not working

Mobile Testing, Android App Testing.
ms_infometis
Posts: 1
Joined: Wed Jan 10, 2018 1:14 pm

PressKeys() in Android not working

Post by ms_infometis » Wed Jan 10, 2018 1:38 pm

Hi

I am trying to automate a Android App. It is based on Angular. To Log in, the user has to enter username and password and then toucht the "Login" button. To set username and password, I need to user the PressKeys - Function, because setting the values to the box will not trigger Angular to bind the content of the boxes to the variables.

Code: Select all

.PressKeys("A");
Also the out-of the box-function "Keypress" does not work and end up in the same error-message.

Unfortunately, this codes produces a "Method not supported" Error. How can I solve this?

thanks
Martin
You do not have the required permissions to view the files attached to this post.

dpFourOFour
Certified Professional
Certified Professional
Posts: 39
Joined: Mon Dec 12, 2016 9:24 am

Re: PressKeys() in Android not working

Post by dpFourOFour » Thu Jan 11, 2018 10:13 pm

Hi ms_infometis,

You might wanna take a look at this posting iOS mobile web, button is clicked but nothing happens

Basically, you need to call the executeScript method on the username and password field to make sure the text change event gets fired. Also, you might need to change the method since this usually depends on the listener your dev team has implemented. Some possible values are
.change()
.trigger()
.keyup()
.keydown()

Hope that helps!
Best,
DP
Please always include the following information to your posts
  • Ranorex Version
  • OS Version

garryjoshi
Posts: 1
Joined: Mon Jan 15, 2018 1:09 pm

Re: PressKeys() in Android not working

Post by garryjoshi » Mon Jan 15, 2018 1:26 pm

I was encountering same method not supported error; however on performing the ExecuteScript you've provided it worked just fine. Thank you so much @ dpFourOFour :)

asishr
Posts: 4
Joined: Tue Mar 27, 2018 3:24 pm

Re: PressKeys() in Android not working

Post by asishr » Tue Mar 27, 2018 3:31 pm

I still have this .presskeys & Mobile key press errors.
I am in the same situation, even tries the provided solution with execute script did not work for me. We are using ionic(Angular) with xamarin. :|

dpFourOFour
Certified Professional
Certified Professional
Posts: 39
Joined: Mon Dec 12, 2016 9:24 am

Re: PressKeys() in Android not working

Post by dpFourOFour » Wed Mar 28, 2018 1:47 pm

Hi asishr,

As mentioned in my previous posting, the method which needs to be called within the execute script could be different than my examples.
Could you talk to your development team if they have implemented a different eventlistener?

Best,
DP
Please always include the following information to your posts
  • Ranorex Version
  • OS Version

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: PressKeys() in Android not working

Post by tvu » Wed Mar 28, 2018 6:12 pm

Hi ms_infometis,

There are two solutions that worked for me in the past.
  • Perform the mobile key press on a repo item higher up the Xpath. For example, performing it on the mobileapp item or the mobileapp/form item. You must touch the text field for the username / password first to bring it into focus before performing the key press.
  • Use ADB to send the text. Like the first method, you must touch the username / password text field first to bring it into focus. You can send text with the command listed below. Use the ADB.exe file in the Ranorex Bin directory and not from Android Studio.

    adb.exe shell input text YOURTEXTSTRING
Hope that helps.

smithclarkson01
Posts: 1
Joined: Wed May 01, 2019 9:03 pm

Re: PressKeys() in Android not working

Post by smithclarkson01 » Wed May 01, 2019 9:05 pm

garryjoshi wrote:
Mon Jan 15, 2018 1:26 pm
I was encountering same method not supported error; however on performing the ExecuteScript you've provided it worked just fine. Thank you so much @ dpFourOFour :)
ExecuteScript is not working for me. tried other methods also which I found on other forums. Nothing seems to work!

tataindicombroadband.in VidMate E sadhana
Last edited by smithclarkson01 on Wed Jul 14, 2021 12:57 am, edited 2 times in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PressKeys() in Android not working

Post by odklizec » Thu May 02, 2019 7:23 am

smithclarkson01 wrote:
Wed May 01, 2019 9:05 pm
ExecuteScript is not working for me. tried other methods also which I found on other forums. Nothing seems to work!
Hi,

Without seeing your app under test, or at very least Ranorex snapshot (NOT screenshot), there is unfortunately very little anyone here can do or suggest. Also, you forgot to mention Ranorex version and type of android application you are automating. Generally speaking, if you carefully followed the steps of all mentioned solutions (especially ADB-related), something should work. But as mentioned, without seeing the app (at very least snapshot), it's impossible to tell what's wrong in your case.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

seoking
Posts: 1
Joined: Mon Apr 29, 2019 1:16 am

Re: PressKeys() in Android not working

Post by seoking » Thu May 02, 2019 9:57 pm

odklizec wrote:
Thu May 02, 2019 7:23 am
smithclarkson01 wrote:
Wed May 01, 2019 9:05 pm
ExecuteScript is not working for me. tried other methods also which I found on other forums. Nothing seems to work!
Hi,

Without seeing your app under test, or at very least Ranorex snapshot (NOT screenshot), there is unfortunately very little anyone here can do or suggest. Also, you forgot to mention Ranorex version and type of android application you are automating. Generally speaking, if you carefully followed the steps of all mentioned solutions (especially ADB-related), something should work. But as mentioned, without seeing the app (at very least snapshot), it's impossible to tell what's wrong in your case.
even for me, I have tried almost everything I could but I think nothings is going to work!! Can you provide me with your email/skype/telegram so that anyone from your team can help me out?

9Apps CArtoon HD SHAREit
Last edited by seoking on Fri May 10, 2019 9:59 pm, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PressKeys() in Android not working

Post by odklizec » Fri May 03, 2019 1:09 pm

Hi,

I'm afraid, I'm not a part of Ranorex support team. I'm a normal Ranorex user, just like you ;) So if you want to contact Ranorex support, you should use their support form, available here:
https://www.ranorex.com/support-query/
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

flisterfour
Posts: 1
Joined: Mon Jan 04, 2021 8:17 am

Re: PressKeys() in Android not working

Post by flisterfour » Mon Jan 04, 2021 9:28 am

I have written custom code to access keyboard

AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.getKeyboard().sendKeys(Keys.RETURN)

But its not working.

rareskysix
Posts: 1
Joined: Thu Apr 22, 2021 6:33 pm

Re: PressKeys() in Android not working

Post by rareskysix » Fri Apr 23, 2021 7:14 pm

tvu wrote:
Wed Mar 28, 2018 6:12 pm
Hi ms_infometis,

There are two solutions that worked for me in the past.
  • Perform the mobile key press on a repo item higher up the Xpath. For example, performing it on the mobileapp item or the mobileapp/form item. You must touch the text field for the username / password first to bring it into focus before performing the key press.
  • Use ADB to send the text. Like the first method, you must touch the username / password text field first to bring it into focus. You can send text with the command listed below. Use the ADB.exe file in the Ranorex Bin directory and not from Android Studio.

    adb.exe shell input text YOURTEXTSTRING
Hope that helps.
Thanx for sharing the solution it helped me.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PressKeys() in Android not working

Post by odklizec » Wed Oct 27, 2021 2:57 pm

its john wrote:
Wed Oct 27, 2021 11:22 am
me also facing this error.
Hi,

So have you tried one of the suggested solutions?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

its john
Posts: 1
Joined: Wed Oct 27, 2021 11:19 am

Re: PressKeys() in Android not working

Post by its john » Mon Nov 01, 2021 1:00 pm

odklizec wrote:
Wed Oct 27, 2021 2:57 pm
its john wrote:
Wed Oct 27, 2021 11:22 am
me also facing this error.
Hi,

So have you tried one of the suggested solutions?
yes.

Benjamins
Posts: 1
Joined: Wed Dec 29, 2021 3:24 pm

Re: PressKeys() in Android not working

Post by Benjamins » Wed Dec 29, 2021 3:26 pm

Hi,
My application is running, I would like to press on overview button and then close the application. Please do let me know how do I do this, Katalon recoder or Spy mobile is not able to recognised the overview button (square button on next home button).