-1

We know that Appium can be used to test mobile device applications. We know that Selenium can be used to test PC desktop websites. We want to know how to test the connections between mobile apps and desktop websites? For example, use the mobile app to send a message to a desktop website, how to automatically send the message from mobile and verify that message is correctly shown on a webpage?

3
  • What have you tried so far? What were the results? Commented Mar 4, 2022 at 8:31
  • @JoãoFarias we can now only use Appium to control mobile device to send message, but to validate the result from PC website, we have to manually check if the result is correct.
    – Zhang Buzz
    Commented Mar 5, 2022 at 2:21
  • We now create a script to run Appium test script first, wait some seconds, and then run selenium test script after it to verify.
    – Zhang Buzz
    Commented Mar 7, 2022 at 9:50

2 Answers 2

1

You can always create a Driver Implementation class that initiates and holds both Selenium Webdriver and Appium driver, can make calls to them as per tests demands. Given, that both will work as different processes (browser, mobile emulator/device) there won't be any clashes to trouble the automated testing services you intend to provide.

A sample implementation can be as follows,

Assuming that your testcase is, Given MyWebApp and MyMobileApp are launched When I can some message from MyMobileApp Then I can see the message in MyWebApp

Then, a pseudo code implementation of it can be as follows,

void testCaseMethod(MyDriverImpl myDriverImpl, String message){

myDriverImpl.getWebDriver().get(MyWebAppUrl); myDriverImpl.getMobileDriver().launchApp();

myDriverImpl.getMobileDriver().findElement(myMobileElementField).sendKeys(message); myDriverImpl.getMobileDriver().findElement(myMobileElementButton).click();

String recievedText = myDriverImpl.getWebDriver().findElement(myWebElementLabel).getText();

assertEquals(message, recievedText); }

class MyDriverImpl{

WebDriver webDriver; AppiumDriver mobileDriver;

DriverImpl(){ webDriver = launchSeleniumWebDriver(); //chrome driver, etc. mobileDriver = launchAppiumDriver(); //android or ios }

WebDriver getWebDriver(){ return webDriver; }

AppiumDriver getMobileDriver(){ return mobileDriver; }

}

1

In my experience, this form of integration testing is rarely done. I've never seen it. Partly, due to the complicated setup that would be involved.

I do see this as a violation of the F.I.R.S.T principle. Commonly used in unit testing, it can also be extended to other types of testing.

  • F - Fast
  • I - Independent
  • R - Repeatable
  • S - Self-validating
  • T - Timely

If you want to test an action on mobile and verify the results on a desktop browser (or vice versa), this would violate "Independence" and "self-validating". You are now having a dependence on multiple devices in order to complete the test and the assertion is not validated on the same device it started on. It would also take a lot of time to setup the right conditions, so in a sense, would not be "timely" to setup.

My recommendation would to not do this and just stick with testing independently on mobile and independently on desktop.

2
  • Thanks for your comment. Seems we can only do this kind of test manually.
    – Zhang Buzz
    Commented Mar 5, 2022 at 2:19
  • I'm not sure that's what Lee is suggesting; I think they're advocating for testing each system separately. If your mobile device tests are able to send messages correctly, and your desktop tests are able to receive messages correctly, then your testing is fine. Testing both at once leads to bad tests. Commented Mar 8, 2022 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.