Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Pass Custom Variables in Automate

How do I pass custom variables specific to different browsers in the yml file?

You can pass custom variables specific to different browsers within the browserstack.yml file. At runtime you can identify these current browser instances and the corresponding custom variables that you declared. The getCurrentPlatform function returns the browser data, and you may retrieve the custom variables related to that browser and manipulate them as needed. This can be useful when testing login functionality and passing different credentials to 3 different browsers.

Here is a sample .yml file with custom variables:

browserstack.yml

The following code snippets show how to get the current platform details using the getCurrentPlatform method. This method also returns an object for the customVariables object.

package com.browserstack;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import com.browserstack.BrowserStackSdk;
import static org.junit.Assert.assertTrue;
public class BStackLocalTest extends BrowserStackJUnitTest {
    @Test
    public void test() {
        System.out.println(BrowserStackSdk.getCurrentPlatform());
        driver.get("http://bs-local.com:45454/");
        assertTrue("Local content not validated!", driver.getTitle().contains("BrowserStack Local"));
    }
}

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle