How to use 1 Driver(Appium) instead of 2 Different Drivers(Appium and Web) for Automation

823 views
Skip to first unread message

SAMNIT CHUGH

unread,
Jul 28, 2017, 12:06:35 AM7/28/17
to Selenium Users
OS: Windows 10
Selenium Version: Selenium 3.4
Browser: Multiple

I am working on a framework based on selenium.
We are creating and executing script of
Web , Android Web and Hybrid App using selenium Grid

For Web , we are using the RemoteWebDriver to initialise the webDriver for all the browsers(Firefox,Chrome,IE) For which the code is : -

WebDriver driver = new RemoteWebDriver(sURL, cap);

For Android Web and Hybrid App we are using AndroidDirver to initialise the AppiumDriver

AppiumDriver driver = new AndroidDriver(sURL, oCap);

Now to perform different validations for Windows Web , we are using WebDriver and to perform validations on Andorid web and Hybrid , We are using Appium Driver.

Now ,typecasting Android Driver to WebDriver is working fine. But when trying to typecast RemoteWebDriver to AppiumDriver it is throwing error :
org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.AppiumDriver

I want to now use only one Driver preferably Appium driver to run the scripts on both Platforms(Windows and Android).
Is there a way of how I can Use only one driver for all type of my Testcases as AppumDriver will give more and better options for automating the hybrid apps on Android ???

Krishnan Mahadevan

unread,
Jul 28, 2017, 12:12:22 AM7/28/17
to seleniu...@googlegroups.com

Assuming that you are pushing in a reference to AppiumDriver into a variable that is of type RemoteWebDriver, you should be able to safely cast it back to AppiumDriver.

Can you please show some code snippets to help us get an idea of what your code looks like ?

The casting should additionally be guarded by an instanceof check as well.

 

 

Thanks & Regards

Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

    --

    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-user...@googlegroups.com.

    To post to this group, send email to seleniu...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ced7b2ea-7f1d-4d99-80e4-793db7f5b340%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

   

Reply all
Reply to author
Forward
0 new messages