-1

enter image description hereThis is my code

public void AccessLogin() throws IOException, InterruptedException {
    
    WebElement oauth = driver.findElement(oAuth);
    oauth.click();
    driver.get("https://login.microsoftonline.com/9b681ea3-df3f-4111-b6aa-88fe01ce2168/oauth2/v2.0/authorize?client_id=ee37b577-2953-4322-bc20-0219dc73bc04&scope=email%20offline_access%20openid%20profile%20User.Read.All%20Group.Read.All&redirect_uri=https%3A%2F%2Fhpr-frontend-v1-test.h2software.nl%2Flogin&client-request-id=07bc035c-321c-4d40-9f5e-12d9b9b585fd&response_mode=fragment&response_type=code&x-client-SKU=msal.js.browser&x-client-VER=2.38.3&client_info=1&code_challenge=bgf5HAV3a1gPr-frqCVl4UR80uQVakEb7qwM0pywJgQ&code_challenge_method=S256&nonce=25e5b77b-078e-4de4-bd68-2fc72184aa8c&state=eyJpZCI6IjhhNDhjNTRlLTk3MjUtNDcwZi1hZjNjLWJiNzdjNWU5MDg2OCIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicG9wdXAifX0%3D");
    Thread.sleep(3000);
    //driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
    WebElement Username = driver.findElement(username);
    
    WebElement Password = driver.findElement(password);
    
    //WebElement SignIn = driver.findElement(btSignIn);
  
    excelUtils.setExcelFile(excelFilePath, "Sheet1");

    for (int i = 1; i <= excelUtils.getRowCountInSheet(); i++) {
    if (excelUtils.getRowCountInSheet() >= i) {
        String usernameValue = excelUtils.getCellData(i, 0);
        String passwordValue = excelUtils.getCellData(i, 1);
        
        Username.sendKeys(usernameValue);
        Password.sendKeys(passwordValue);
        WebElement SignIn = driver.findElement(btSignIn);
        SignIn.sendKeys(Keys.ENTER);
        
    }else {
        System.out.println("Row " + i + " does not exist in the Excel sheet.");
    }
    }
}
2
  • Welcome to the community! It would be helpful if you added more than just code to your question. What errors are you getting? What have you tried to solve the problem?
    – Lee Jensen
    Commented Nov 9, 2023 at 20:11
  • Thank you, I am not getting any errors in the Eclipse IDE, the test getting passed, but SignIn doesn't work. when I enter username and password using Excel, and when I click the SigIn button the test getting closes. Commented Nov 10, 2023 at 2:43

1 Answer 1

0

Issue Resolved.

By btSignIn = By.xpath("//input[@value='Sign in']"); - we have to mention the value here. it is the best option.

public void AccessLogin() throws IOException, InterruptedException {

    WebElement oauth = driver.findElement(oAuth);
    oauth.click();
    driver.get("the website url");
    Thread.sleep(3000);
    // driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
    Element(oAuth).click();

    WebElement Username = driver.findElement(username);

    WebElement Password = driver.findElement(password);

    excelUtils.setExcelFile(excelFilePath, "Sheet1");

    for (int i = 1; i <= excelUtils.getRowCountInSheet(); i++) {
        if (excelUtils.getRowCountInSheet() >= i) {
            String usernameValue = excelUtils.getCellData(i, 0);
            String passwordValue = excelUtils.getCellData(i, 1);

            Username.sendKeys(usernameValue);
            driver.findElement(btNext).click();
            Password.sendKeys(passwordValue);
            driver.findElement(btSignIn).click();
            Thread.sleep(2000);
            driver.findElement(btYes).click();
            Thread.sleep(3000);

            // WebElement SignIn = driver.findElement(btSignIn);
            // SignIn.sendKeys(Keys.ENTER);

        } else {
            System.out.println("Row " + i + " does not exist in the Excel sheet.");
        }
    }

}

public void OAuthLogin() throws InterruptedException {
    driver.findElement(oAuth).click();
    Thread.sleep(5000);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.