Mobile Browser Automation using Selenium

On This Page Selenium for Mobile Browser AutomationFebruary 13, 2026 · 11 min read · Mobile Testing

Mobile Browser Automation using Selenium

A is inevitable for any business to flourish. The number of mobile users is greater than desktop users, as the incursion of mobile phones is more compared to computer.

Wandering companies are unloosen new models with new pattern, screen resolutions, and processors every year to attract buyers. Hence, have always been challenging due to, nevertheless, it is an indispensable part of mobile development.

Let ’ s understand how to streamline the examination by opting for using Selenium.

Selenium for Mobile Browser Automation

is a democratic mechanization entourage for and Appium is the best when it come to automate mobile applications. To screen web applications in mobile browsers, Selenium can be used with the.

In Selenium 3, JSON Wire protocol is apply to communicate with the web browsers while the web browsers act on W3C (World Wide Consortium) protocol. This take to APIs encoding and decoding at the client level.

  • WebDriver APIs in follow the W3C in its execution. All the democratic browsers such as Chrome, Firefox, Safari, and IE are W3C compliant.
  • And as Selenium 4 is use W3C, automation tests run consistently across all the W3C-compliant web browsers.
  • Selenium supports many languages such as Java, C #, Python, and Ruby.
  • With Selenium 4, the test can directly transmit with the web browser as JSON Wire Protocol is extinguish.

is an open-source instrument for automating native, mobile web, and hybrid applications on iOS, Android, and Windows. It is a server written on node.js that works on client-server architecture. According to the client-server architecture, the client connects to the server to avail of any service hosted on the waiter. Any communication between the client and server is in the form of responses and requests.

Like Selenium, Appium also support multiple languages such as Java, Objective-C, JavaScript, PHP, Ruby, Python, and C #.

Getting Started with Mobile Browser Automation Testing

Selenium Mobile Browser Automation

  1. Install and Configure Android SDK
  2. Install Node.js and Appium Server
  3. Write Mobile Web Browser Automation Test Script and Execute

To get started with peregrine web browser automation examination, you foremost ask to install Android SDK, Node.js, and Appium.

1. Install and Configure Android SDK

Download Android SDK and set “ ANDROID_HOME ” path in System Environment Variables by following the below steps:

Step 1& # 8211; Download Android SDK command-line puppet fromAndroid Studio functionary pagefor Windows/iOS.

Step 2& # 8211; Create a folder as “Android” at the desired file location, simulate the command-line zip file in the“Android”folder and extract the contents.

Step 3& # 8211; Within the“Android”folder, create a new leaflet “cmdline-tools”. And under “cmdline-tools” folder, make a “tools” folder.

Step 4& # 8211; Now, move the extracted substance to the“Tools”brochure. Net contents of“tools”booklet should look like below.

Step 5& # 8211; Navigate to the bin folder and open the command prompt. Type “ sdkmanager & # 8211; lean ”. This will show a leaning of installed, valid bundle as well as those that can be updated.

Step 6& # 8211; To establish the platform tools type below bid in dictation prompting

sdkmanager “ platform-tools ” “ platforms; android-33 ”

“33”is the up-to-the-minute Android API adaptation. To choose an API version of the Android device under test, referAndroid version history Wikipedia page.

Step 7& # 8211; After the platform tools are download, “platforms” and “ platform-tools ”folders should be populate under“ Android folder ”. “ platform-tools ”contains “adb.exe” which helps in find the Android device when connect to the system.

Step 8& # 8211; Set “ANDROID_HOME” path in the scheme surround variable.

Step 9& # 8211; Go to Settings in the Android phone under test and enable the “Developer Options” so that scheme can observe the earphone when connected.

Step 10& # 8211; Connect the phone via USB cable, open the command prompting in the system, and typewrite the command as “adb device” to get the list of devices attached.

2. Install Node.js and Appium Server

Step 1& # 8211; Download Node.js from itsofficial page. Once downloaded, run the installer. This will establish node.js and npm and will be available under the “C: \Program Files\nodejs” folder in the scheme.

Step 2& # 8211; To check whether node is installed open a new command prompt and type.

node -v

Step 3& # 8211; To insure whether node is installed type

npm -v

Step 4& # 8211; To establish Appium enter below command on the command prompt.

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

npm install -g appium

Step 5& # 8211; Once download, check that Appium is installed by typing the dictation

appium -v

Step 6& # 8211; Type “appium” and hit Enter. The Appium server should start on localhost port 4723 which is the default port for Appium. To quit the Appium server insistence “Ctrl+C”.

The twist is connected to the scheme, listed via adb and the Appium server is also lam.

Now you can start with the first Mobile web browser automation script.

3. Write Mobile Web Browser Automation Test Script

Step 1& # 8211; In any Java editor, create a Maven project and add Selenium Java, Java guest and TestNG addiction under& lt; dependencies & gt; tag in pom.xml.

& lt; dependencies & gt; & lt; dependency & gt; & lt; groupId & gt; org.seleniumhq.selenium & lt; /groupId & gt; & lt; artifactId & gt; selenium-java & lt; /artifactId & gt; & lt; variation & gt; 4.5.0 & lt; /version & gt; & lt; /dependency & gt; & lt; dependency & gt; & lt; groupId & gt; io.appium & lt; /groupId & gt; & lt; artifactId & gt; java-client & lt; /artifactId & gt; & lt; version & gt; 8.2.0 & lt; /version & gt; & lt; /dependency & gt; & lt; dependency & gt; & lt; groupId & gt; org.testng & lt; /groupId & gt; & lt; artifactId & gt; testng & lt; /artifactId & gt; & lt; variation & gt; 7.6.1 & lt; /version & gt; & lt; scope & gt; compile & lt; /scope & gt; & lt; /dependency & gt; & lt; /dependencies & gt;

Step 2& # 8211; Under “src/test/java” create a package and under that software, create a class as “AndroidChromeTest”.

Step 3& # 8211; Create a WebDriver case as we do in Selenium Web automation.

WebDriver driver;

Step 4& # 8211; Create a ChromeOptions case to set Chrome Driver and Android device details.

ChromeOptions options=new ChromeOptions ();

Step 5& # 8211; Create a URL class case to store the speech of Appium server.

URL url=new URL (``http: //localhost:4723/wd/hub");

Step 6& # 8211; Create AndroidDriver instance and pass Appium remote server address and Desired Capabilities instance.

driver = new AndroidDriver (url, options);

Step 7& # 8211; Below code set the desired details for the Android device and Chrome browser nowadays in Android device

@ BeforeMethod public void setUp () shed MalformedURLException {options.setPlatformName (`` Android ''); options.setAndroidDeviceSerialNumber (`` N000TA1183962301141 ''); options.setBrowserVersion (`` 106 ''); //Appium server details url = new URL (`` http: //localhost:4723/wd/hub ''); driver = new AndroidDriver (url, pick);}

Step 8& # 8211; This completes the apparatus and we are good to start interacting with the browser. Below code launching BrowserStack official website, and verifies that the title is as await or not.

@ Test public void verifyTitle () throws MalformedURLException {driver.get (`` https: //www.browserstack.com/ ''); Assert.assertEquals (driver.getTitle (), `` Most Reliable App & amp; Cross Browser Testing Platform | BrowserStack '');}

Above program demonstrates testing of Mobile Chrome browser in Android Phone. To test in any other OS or browser Desired Capabilities should be set consequently.

Why is Cross Browser testing necessary?

Websites are built using different technologies such as HTML, Javascript, CSS, PHP, etc. Every browser has its own engine to render web pages. With this, it is evident it will charge, carry, and look slimly different in different browsers. verifies that the website is supply properly across multiple browsers and is crucial for ensuring that the ware experience is consistent.

In the parallel domain, Web Browser companionship are releasing new versions of browsers really oftentimes. Again, testing websites against new browser versions is obligatory.

Selenium for Cross-Browser Testing

Implementing cross-browser examine manually seems impossible as there is a pool of mobile device case, platforms (Android/ iOS), browser eccentric (Chrome/ Firefox/ Safari), and browser versions uncommitted in the market. along with the TestNG model can be used by pass browser values from testing.xml file and with the assistant of @ Parameters annotating.

Using BrowserStack to achieve Cross Browser Testing

leverages testing of mobile/web service by render 3000+ real devices and browsers for comprehensive examination of the website and roving applications for functionality, performance, and visual charm to release bug-free software faster and at scale.

Testers can easy trade between device, platforms, browser, and browser variation thereby achieving cross-platform and crisscross browser examination.

How to Test Mobile Web Browsers on BrowserStack Real Device Cloud

offers 3500+ existent browser and devices to prove on using its. Testing on helps you get exact test results. Here are the steps to test roving web browser on BrowserStack Automate:

Step 1& # 8211; and create a gratuitous account. After successful chronicle creation, you can view the Authentication and Security details under the Summary tab.

Step 2& # 8211; Navigate to Capabilities Generator page to select from a comprehensive set of options.

Step 3& # 8211; Choose your coveted combination of device-browser from thousands of uncommitted combinations. In the below example, Android Google Pixel 6 Pro, OS 13 with Chrome browser are selected.

Step 4& # 8211; In any java editor, create a Maven project and add Selenium Java and Java client dependence.

& lt; dependencies & gt; & lt; dependency & gt; & lt; groupId & gt; org.seleniumhq.selenium & lt; /groupId & gt; & lt; artifactId & gt; selenium-java & lt; /artifactId & gt; & lt; edition & gt; 4.5.0 & lt; /version & gt; & lt; /dependency & gt; & lt; dependance & gt; & lt; groupId & gt; io.appium & lt; /groupId & gt; & lt; artifactId & gt; java-client & lt; /artifactId & gt; & lt; edition & gt; 8.2.0 & lt; /version & gt; & lt; /dependency & gt; & lt; dependence & gt; & lt; groupId & gt; org.testng & lt; /groupId & gt; & lt; artifactId & gt; testng & lt; /artifactId & gt; & lt; version & gt; 7.6.1 & lt; /version & gt; & lt; reach & gt; compile & lt; /scope & gt; & lt; /dependency & gt; & lt; /dependencies & gt;

Below program showcases the Chrome browser essay on Google Pixel 6 Pro on the real device cloud.

public class AndroidTestBS {public static String username = `` & lt; browserstack_username & gt; ''; public static String accesskey = `` & lt; browserstack_accesskey & gt; ''; public static final String URL = `` https: // '' + username + ``: '' + accesskey + `` @ hub-cloud.browserstack.com/wd/hub ''; WebDriver driver; String url = `` https: //www.browserstack.com/ ''; MutableCapabilities capabilities = new MutableCapabilities (); HashMap & lt; String, Object & gt; browserstackOptions = new HashMap & lt; String, Object & gt; (); @ BeforeMethod public void setUp () throws MalformedURLException {browserstackOptions.put (`` browserName '', `` chrome ''); browserstackOptions.put (`` deviceName '', `` Google Pixel 6 Pro ''); browserstackOptions.put (`` realMobile '', `` true ''); browserstackOptions.put (`` osVersion '', `` 13 ''); capabilities.setCapability (`` bstack: pick '', browserstackOptions); driver = new RemoteWebDriver (new URL (URL), capabilities);} @ Test (precedence = 1) public void verifyTitle () {driver.get (url); System.out.println (driver.getTitle ()); Assert.assertEquals (driver.getTitle (), `` Most Reliable App & amp; Cross Browser Testing Platform | BrowserStack '');} @ Test (priority = 2) public void verifyDashboard () {driver.get (url); WebElement getStarted = driver.findElement (By.cssSelector (`` a # signupModalButton '')); getStarted.click (); Assert.assertEquals (driver.getTitle (), '' Get Started For Free & amp; Access 3000+ Mobile Devices & amp; Browsers | BrowserStack '');} @ AfterMethod public emptiness tearDown () {driver.quit ();}}

Below programme illustrates Safari browser test on iPhone 11 the real device cloud.

@ BeforeMethod public void setUp () shed MalformedURLException {browserstackOptions.put (`` browserName '', `` safari ''); browserstackOptions.put (`` deviceName '', `` iPhone 11 ''); browserstackOptions.put (`` realMobile '', `` true ''); browserstackOptions.put (`` osVersion '', `` 14 ''); capabilities.setCapability (`` bstack: choice '', browserstackOptions); driver = new RemoteWebDriver (new URL (URL), capabilities);}

After running the above programs, you can check the upshot on the page. You also get to see the execution video. You can get access to text, network, and former log. And it captures Appium logarithm too!

In short, all the surroundings details and desired capabilities are available for each run on the Automate splashboard page.

After seeing the above implementation it & # 8217; s quite evident that BrowserStack facilitates QA team to action on multiple browsers to do certain the build meets browser compatibility benchmark. It decimate the complexness of downloading Android SDK, Appium, and Node to reach web mobile automation examine in a traditional way.

Why use BrowserStack Automate to run Selenium Tests?

You should run Selenium Java Tests on a real twist cloud like for below reasons:

  • Realistic Testing Conditions: provide access to a extensive spectrum of device and surroundings, ensuring exam ruminate actual user conditions accurately.
  • Enhanced Security: Maintained with high protection standards, real twist clouds offer secure, isolated testing environments, minimizing data breach endangerment.
  • Broad Browser and OS Coverage: Helps place compatibility number across various browsers and go systems, enhancing user experience.
  • Performance Insights: Real devices yield authentic performance data essential for optimizing coating reactivity.
  • Scalability and Accessibility: Facilitates scalable and accessible testing, suitable for distributed teams.
  • CI/CD Integration: Integrates swimmingly with CI/CD line for uninterrupted testing and early subject detection.
  • Cost-Effectiveness: Although initially more high-priced, it saves on long-term expenses related to fixes and support.

Conclusion

In today ’ s software mechanization world, uninterrupted maturation, and continuous deployment is the key objective of development environments. and are the two democratic and potent testing automation creature that help testers integrate continuous testing. It supports multiple browser, program, and go systems.

As the gatekeeper of any product, it is the responsibility to test the product on existent devices, program, and browsers before release it in production.

BrowserStack speak all these concerns by providing 3000+ real devices and browser. It supports cross-browser examination and deliver a seamless user experience across browsers and device.

Tags
55,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free