Testing Real-Time User Interaction Using Multiple Simultaneous Appium Sessions
Many of the apps that we use, and take to test, involve the real-time interaction of multiple exploiter, who are sitting in front of their own device or browser. The & quot; standard & quot; Appium exam involves one driver aim, representing one Appium session, automate a single device. How can we extend our usage of Appium so that we canco-ordinatemultiple devices, the way multiple users would spontaneously coordinate their own behavior? First, let & # x27; s take a look at some common use instance for a multi-user or multi-device examination: Of course, lots of other apps involve user interaction that isn & # x27; t necessarily real-time. Any social app, for example, will have the ability for users to care or comment on other users & # x27; situation. In a normal case, it would be potential to conceive of this as pass asynchronously, not in real time. But many of these like apps too desire to be able to test that the UI is updated in real time, when another user interacts with some content. So, for model, when I & # x27; m using Twitter, I get an in-app notification (rather than a system notice), if someone likes or retweets one of my situation. Testing this peculiar feature expect the like kind of multi-user interaction we & # x27; re talking about here. The basic point I want to convey in this guide is thatAppium needs no particular help to accommodate a multi-device, multi-user, real-time test scenario. This is true because of the following facts about Appium (which you might already be aware of): These two facts make it technically trivial (if not incessantly intuitive from a test development perspective) to implement real-time multi-device stream. Now, there is a little caveat on number 2 above -- -because Appium sessions utilize certain scheme resource (primarily TCP ports) to communicate with specific device, if you want to run multiple Appium sessions at erstwhile on a individual machine, you & # x27; ll postulate to include some capabilities that direct Appium to use specific ports for each session. This information has already be covered in the Appium Pro article on. There is no difference from Appium & # x27; s view between the like examination being run in analog on different devices, or one test incorporating multiple devices to test a user interaction flow. SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses. To showcase multi-device examine with Appium, I developed a simple chat application, calledAppium Pro Chat. It & # x27; s a non-persisent multi-channel chat room, with zero memory, data storage, or (I hesitate to add) security. Feel gratis to go try it out in your browser! You can open up two browsers or tabs, cull a username, and join the same channel to see it in activity. The basic test that I will implement is this: It & # x27; s a bare tryout, but one that has to affect the coordination of multiple Appium devices and multiple Appium sessions. For this example, I am going to use an iOS simulator for User 1, and an Android device (Galaxy S7) for User 2. The initiative thing I need to do is make sure that I can begin an Appium session on each of these, so I & # x27; ve create a helper method for each that only returns an Appropriate driver case. Now, in my test setUp method, I make sure to instantiatebothdriver, which are store as fields in my form, for example (omitting the other features of this class): You can see that there & # x27; s nothing exceptional to get multiple sessions depart at the same time -- -I just first create the session on Safari on iOS, so the one on Chrome on Android. Setup and teardown now handle two driver, instead of one. In this instance, I am instantiating these sessions serially; if I wanted to optimize further, I could potentially instantiate them at the like clip in separate threads, but it impart unnecessary complexity at this point. Now, we need to use both of these drivers (the safari and chrome objects) in such a way that they interact in real time with one another, in the course of a single trial. Before I show the test method itself, I & # x27; ll excuse the plan: each of the two user will merchandise line from the knock-down Langston Hughes poemHarlem. To encapsulate the data which will be used to support the test, we & # x27; ll add it all as a set of fields at the top of the course: (Note that I have, possibly ill-advisedly, but I believe in line with the feeling of the poem, impart a final line of my own, partly to get User 2 & # x27; s list of messages equalize the length of User 1 & # x27; s). With the data set up in ImmutableLists, we & # x27; re in a position to iterate over the chats and implement the user interaction in a very concise way. Next, I wanted to create a set of helper method to make it potential to reuse functionality between the two users. Both users will have to login and join a groove, and both users will have to send messages. Likewise, we can read the chat log from the perspective of either user. So we can factor all of this out into appropriate helper method: Note that each of these lead a RemoteWebDriver object, because that is the appropriate superclass of both IOSDriver and AndroidDriver. We don & # x27; t know within these methods whether we & # x27; re automating iOS Safari or Android Chrome, and that & # x27; s a full thing. It maintain the code general. Now, we can encrypt up the test itself: As you can see, it & # x27; s fairly stocky. We induce each of the clients to join the same groove, then iterate over their various list of chat messages, sending each one to the groove. Finally, I retrieve the chat log from one of the users, and print it out to the console. Of course, in an actual tryout, we could make assertions on the substance of the messages box, or yet assert appropriate similarity between the chat lumber see by each user. Finally, for visual impact while running the tryout, we wait for 4 seconds before close everything down (again, this would not be the cause in an actual test). That & # x27; s really all there is to it! Let me highlight the scheme we & # x27; ve direct hither, in a way that could be adapted to any multi-user flow: Want to have a look at the full codification sampling for this multi-user flow?Check it out on GitHub! And by all agency, let me know if you & # x27; ve implemented any interesting multi-user or multi-device flow with Appium. Lead, Content Marketing, HeadSpin Inc. Piali is a dynamic and results-driven Content Marketing Specialist with 8+ years of experience in crafting engaging narratives and marketing collateral across diverse industry. She excels in collaborating with cross-functional teams to germinate innovative substance strategies and deliver compelling, veritable, and impactful content that resonates with target hearing and enhances make authenticity. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts..png)



Testing Real-Time User Interaction Using Multiple Simultaneous Appium Sessions
AI-Powered Key Takeaways

Examples of multi-user interaction
Background for a multi-device flow
Our multi-user AUT
Multi-device setup
private IOSDriverpublic class Edition118_Multi_Device {private IOSDriverCoordinating multiple driver within a single test
private static final String CHAT_URL = `` https: //chat.appiumpro.com ''; individual static final String CHANNEL = `` Harlem ''; private electrostatic final String USER1_NAME = `` Langston ''; private static final String USER2_NAME = `` Hughes ''; individual static final ImmutableListindividual void joinChannel (RemoteWebDriver driver, String username, String channel) throw MalformedURLException {WebDriverWait wait = new WebDriverWait (driver, 10); driver.navigate () .to (new URL (CHAT_URL)); wait.until (ExpectedConditions.presenceOfElementLocated (By.cssSelector (`` # channel ''))) .sendKeys (channel); driver.findElement (By.cssSelector (`` # username '')) .sendKeys (username); driver.findElement (By.cssSelector (`` # joinChannel '')) .click ();} individual void sendChat (RemoteWebDriver driver, String message) {WebDriverWait wait = new WebDriverWait (driver, 10); wait.until (ExpectedConditions.presenceOfElementLocated (By.cssSelector (`` # sendMessageInput ''))) .sendKeys (content); driver.findElement (By.cssSelector (`` # sendMessageBtn '')) .click ();} private String getChatLog (RemoteWebDriver driver) {WebDriverWait wait = new WebDriverWait (driver, 10); return wait.until (ExpectedConditions.presenceOfElementLocated (By.cssSelector (`` # messages ''))) .getText ();}@ Test public nothingness testChatApp () throws MalformedURLException {joinChannel (safari, USER1_NAME, CHANNEL); joinChannel (chrome, USER2_NAME, CHANNEL); for (int i = 0; i< USER1_CHATS.size(); i++) {
sendChat(safari, USER1_CHATS.get(i));
sendChat(chrome, USER2_CHATS.get(i));
}
System.out.println(getChatLog(chrome));
try { Thread.sleep(4000); } catch (Exception ign) {}
}
Recap
Piali Mazumdar
Testing Real-Time User Interaction Using Multiple Simultaneous Appium Sessions
4 Parts
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for forward-looking users (Part 3)
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for forward-looking users (Part 4)
Discover how HeadSpin can empower your business with superior examine capabilities







Discover how HeadSpin can empower your business with superior essay capableness
Discover how HeadSpin can empower your line with superior testing capabilities
Connet Now


Automate This With SUSA
Test Your App Autonomously







.png)












