0

Can anyone please help me to start browserstack locale as a background process in jenkins using WINDOWS for protractor end to end testing .

I was going through this link but this is for linux,I need for windows . https://janmolak.com/jenkins-2-0-pipelines-and-browserstack-bd5a4ed3010d#.gf9pxyhgc I have already installed browserstack binary for win 32 in jenkins.

2 Answers2

0

Have you tried the Jenkins plugin for BrowserStack? You can refer to the details here - https://www.browserstack.com/automate/jenkins.

Since you are not using Java you will not be able to use the reporting functionality of the plugin. You can however use the following features that the plugin offers.

1) Manage your BrowserStack credentials globally or per build job.

2) Set up and teardown BrowserStackLocal for testing internal, dev or staging environments.

  • yes I am using browserstack plugin but before running the test i need to start browser stack locale other wise I will get the following error [Internet Explorer #21] WebDriverError: [browserstack.local] is set to true but local testing through BrowserStack is not connected. – Anisha RK nair Mar 16 '17 at 11:05
  • I have created project build as pipeline in Jenkins, so as mentioned in the document I don't see build configuration option under pipeline to set browser stack local options.Is there any option to set it through pipe line script – Anisha RK nair Mar 16 '17 at 11:20
  • I understand you have selected the option "BrowserStack Local" in your Job config. Here, the plugin adds a "--local-identifier" option with a unique value when starting the binary. You need to add this unique value in your test scripts. Have you added the capability "String browserstackLocalIdentifier = System.getenv("BROWSERSTACK_LOCAL_IDENTIFIER");" AND "capabilities.setCapability("browserstack.localIdentifier",browserstackLocalIdentifier);" in your scripts? – Ashwin Gonsalves Mar 16 '17 at 11:31
  • I am using capabilities in browserstack configuration file and I dont set browserstackLocalIdentifier in browserstack configuration file. – Anisha RK nair Mar 16 '17 at 11:55
  • want to use my pipeline definition like this ,but this is for linux I need for windows . Please see the pipe script I referred, node { //Start the connection sh "BUILD_ID=dontKillMe nohup /var/tmp/BrowserStackLocal 42MyAcc3sK3yV4lu3 -onlyAutomate > /var/tmp/browserstack.log 2>&1 & echo \$! > /var/tmp/browserstack.pid" // Execute tests [...] // Stop the connection sh "kill `cat /var/tmp/browserstack.pid`" } – Anisha RK nair Mar 16 '17 at 11:56
  • If you are using the Jenkins plugin with the option "BrowserStack Local" selected then you need to add the capabilities I mentioned above. Else you will receive the error " [browserstack.local] is set to true but local testing through BrowserStack is not connected". Coming to the command you've shared I'm afraid I do not have any info on converting it for Windows. – Ashwin Gonsalves Mar 16 '17 at 12:07
0

Here's how I got it working:

  1. Install the BrowserStackLocal binary from their website.
  2. Install the Jenkins Browserstack Plugin how to
  3. Configure the plugin with your username and access key and point it at the downloaded binary.
  4. In order for the session to route ip traffic locally, we have to pass a local identifier from the binary into our desired capabilities when the test runs. (as Ashwin Gonsalves pointed out.)

    public DesiredCapabilities GetCapabilities(Browser browser, bool isBSLocal)
    {
        DesiredCapabilities capability = new DesiredCapabilities();
    
        // Get BSID for local ip routing
        if (isBSLocal) 
        {
            string BSID = System.Environment.GetEnvironmentVariable("BROWSERSTACK_LOCAL_IDENTIFIER");
            capability.SetCapability("browserstack.localIdentifier", BSID);
        }
    
        switch (browser.ToString())
        {
            case "Chrome":
                capability.SetCapability("os", "Windows");
                capability.SetCapability("os_version", "10");
                capability.SetCapability("browser", "Chrome");
                capability.SetCapability("browser_version", ChromeVersion);
                capability.SetCapability("browserstack.chrome.driver", "2.42");
                capability.SetCapability("resolution", "1920x1200");
                capability.SetCapability("project", TestOps.GetParent);
                capability.SetCapability("name", TestOps.GetTestName);
                capability.SetCapability("browserstack.local", "true");
                capability.SetCapability("browserstack.debug", "true");
                capability.SetCapability("browserstack.selenium_version", ChromeSeleniumVersion);
                capability.SetCapability("browserstack.user", USERNAME);
                capability.SetCapability("browserstack.key", AUTOMATE_KEY);
                break;
    
LoflinA
  • 350
  • 4
  • 19