Is it possible to use Selenium's RemoteWebDriver and Appium's AppiumDriver in parallel?

3.6k views Asked by At

I'm trying to write some test scripts which involves uploading a file via Chrome. I'm using Selenium's RemoteWebDriver in order to test the web application using Chrome on a Samsung Note 10 device.

I've managed to write the script up to the point of clicking on the file upload button which in turn bring up the file upload control asking me which type of file I'd like to upload. However since this is not a web control I can't interact with it using RemoteWebDriver. I tried to create a new instance of AppiumDriver but since an instance of RemoteWebDriver already exists I'm unable to create a new instance of AppiumDriver.

Is there anyway I could go about this issue? I tried to cast RemoteWebDriver as a AppiumDriver (despite feeling that it wouldn't work) but it wasn't possible.

1

There are 1 answers

0
Johnny On

You can start the test with AndroidDriver initialization instead of RemoteWebDriver.

The reason to this is its implementation:

AndroidDriver extends AppiumDriver extends DefaultGenericMobileDriver extends RemoteWebDriver

So, you will have something like:

WebDriver driver = new AndroidDriver(new URL(YOUR_REMOTE_MACHINE_HUB_URL), capabilities);

Now, you can use AppiumDriver methods. You can upload file with in-built technique that WebDriver provide for this.
The main idea behind it is to directly send the absolute path to the file to an element which you would usually click at to get the modal window - that is <input type='file' /> element.

WebElement fileInput = driver.findElement(By.xpath("//input[@type='file']"));
fileInput.sendKeys("C:/file_to_upload.jpg");