简体   繁体   中英

How to make a selenium grid test to login simultaneously

I have a test case that runs using grid. What I want to achieve is executing three different test cases all clicking on login button at the exact same time. When I run pure grid there is always a delay between browsers. How to achieve this using selenium grid and Java?

BR

I solved this issue using a lock and synchronized function. Threads almost click login button Simultaneously

public class Test extends AstractTest {
 private static int lock = 0;    //Here the lock is initiated once

@DataProvider(name = "Test", parallel = true)
public Object[][] loadInputDataFromExcel() {
    return Taf.files().populateExcelDataProvider(getGlobalInputDataFileName("testsConfig"));
}

@Test(description="Simultaneous Login", dataProvider="Test", enabled=true)
public void SimultaneousLogin(Map<String, String> dp) throws InterruptedException {

    setupThreadedBrowserDriver(dp.get("browser")); 

    actionNavigateToPage(dp.get("url"));

    LoginPage loginPage = new LoginPage();

    loginPage.login(dp.get("PersonalNumber"), "password");
    lock++;
    // surround the login button with synchronized block
    synchronized (this) {
        while (lock < 3)
            this.wait();
        this.notifyAll();
        loginPage.loginBtn.clickButton();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM