Clicky

Selenium browser automation

Updated 1 month ago by Daniel

Browser automation allows you to automate tasks inside Multiloginapp browser profiles. From creating simple automation scripts to complex web crawlers that search, collect and interact with web data.

Multiloginapp browser automation is based on the Selenium WebDriver.

In the usual scenario, if you are running Selenium code, you would first connect to Firefox (Gecko) or Chrome driver first and then set desired capabilities. When using Multiloginapp with your Selenium code, you do not need to do that. Instead, you use the Remote Web Driver to connect to Multiloginapp application via the local port and set desired capabilities to execute Selenium commands in a pre-defined browser profile.

Supported languages

Because Selenium framework offers a variety of language bindings, Multiloginapp automation can be also run on multiple coding languages.  However, currently, technical support is only provided for Java language.

Examples

Java

// import the following frameworks
          
          import org.apache.http.client.utils.URIBuilder;
          import org.junit.Assert;
          import org.junit.Test;
          import org.openqa.selenium.remote.DesiredCapabilities;
          import org.openqa.selenium.remote.RemoteWebDriver;
          import java.net.URI;
          
             public class BrowserAutomationRemoteWebDriverSample {
          
                public void simpleTest() throws Exception {
          
                  //TODO replace with existing profile ID. Define the ID of the browser profile, where the code will be executed.
                  String profileId = "xxx";
          
                  // define Multiloginapp local port
                  int mlaClientPort = 35000;
          
                  // define the URL where the Remote Web Driver should connect to
                  URI url = new URIBuilder("http://127.0.0.1:" + mlaClientPort + "/api/v1/webdriver").build();
          
                  // set desired capabilities to connect to a pre-defined browser profile
                  DesiredCapabilities dc = new DesiredCapabilities();
                  dc.setCapability("multiloginapp-profileId", profileId);
          
                  //instantiate the Remote Web Driver to connect to a Multiloginapp local connection
                  RemoteWebDriver driver = new RemoteWebDriver(url.toURL(), dc);
          
                  //perform automation
                  driver.get("http://multiloginapp.com/");
                  Assert.assertTrue(driver.getPageSource().contains("Multiloginapp"));
                  driver.quit();
          
               }
             }
          
          

Python

// import selenium framework
          from selenium import webdriver
          
          //TODO replace with existing profile ID. Define the ID of the browser profile, where the code will be executed.
          mla_profile_id = 'profileID'
          
          // define Multiloginapp local port
          mla_port = '35001'
          
          // define the URL where the Remote Web Driver should connect to
          mla_url = 'http://127.0.0.1:' + mla_port + '/api/v1/webdriver'
          
          // set desired capabilities to connect to a pre-defined browser profile and instantiate the Remote Web Driver to connect to a Multiloginapp local connection
          driver = webdriver.Remote(command_executor=mla_url, desired_capabilities={'multiloginapp-profileId': mla_profile_id})
          
          //perform automation
          driver.get('https://multiloginapp.com')
          assert "Multi-Login" in driver.title
          driver.quit()
          


Was this article helpful?