@pr4bh4sh @Priyank_Shah @wreed
pressKeyCode is not available in AppiumDriver?
As per appium documentation, IOSDriver and AndroidDriver both extend AppiumDriver
Thanks,Sanoj
I've asked you to include your language, but you don't remember or something. In Ruby it's press_keycode, maybe that's what you should use?
http://www.rubydoc.info/github/appium/ruby_lib/Appium%2FDevice%3Apress_keycode
am using java language
are you using AppiumDriver, if thats the case, then you need to cast your driver with (AndroidDriver, not sure about IOSDriver).
((AndroidDriver)driver).pressKeyCode(<>);
Thanks,Priyank Shah
Thanks @Priyank_Shah for the reply and I tried ((AndroidDriver) driver) .pressKeyCode(AndroidKeyCode.ENTER);
getting following error:
cannot be cast to io.appium.java_client.android.AndroidDriver
@sanoj27I think @Priyank_Shah has answered your question. As @wreed said, you should always try to provide these1. Programming language2. Language client version eg. java client, python client3. Appium server version4. Node version (sometimes node version also impacts the issue)5. Stack trace(if stack trace is long please provide this in gist, you don't know how good it feels when someone provides stack trace in gist.)6. Anything seem related to issue.
And at the end before submitting, get someone(anyone) sitting beside you and ask their opinion on what you have provided seems understandable or not to other people.
P.S. I used to do the same, until someone pointed it out. So you are not alone.
@Priyank_Shah and @wreed I think we should ask mods to make a guidelines post.
It has nothing to do with node version, but i recently tried with same java-client and it worked perfectly. Will you please send a line of code, how do u initialize driver object?
Are you running an iOS, Android, or Firefox OS test? Only the Android driver has a pressKeyCode method, since pressing a key code only makes sense in an Android context. Android devices have a home button, back button, and a few other buttons that iOS devices do not. Additonally, iOS UiAutomation tests, as they are now, do not allow tests to simulate actions such as pressing the iOS home button.
If this is a non-Android test, what particular reason makes you want to call a pressKeyCode method?
@afwang This is specific to Android test.
I have declared and initialized driver in AutomationBase class as follows:
public AppiumDriver driver;
driver = new AppiumDriver(url, capabilities) {
@Override public MobileElement scrollToExact(String arg0) { return null; } @Override public MobileElement scrollTo(String arg0) { return null; } };
This is not correct way to initialized driver. You need to assinged as android Driver.
IOSDriver and AndroidDriver both extend AppiumDriver?
Yes.
I'm facing the same issue with AndroidDriver.driver.pressKeyCode(66);
Programming language = JavaLanguage client version = Java client 3.3.0/3.2.0Appium server version = Appium v1.4.13
LOGS:
how do u instantiate your driver object? r u using AppiumDriver or AndroidDriver?
Android driver it is.The problem lies with the button itself. I'm able to perform this action on some other screen, but not in one certain case.