Microsoft Account SignIn button is not Working when I tetsted with Selnium and Java

37 views Asked by At

enter image description here`public DDLogin_Page(WebDriver driver) { this.driver = driver; }

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 signInButton = driver.findElement(By.id("idSIButton9"));
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("arguments[0].click();", signInButton);

    
    
   // WebElement SignIn = driver.findElement(btSignIn);
   // SignIn.sendKeys(Keys.ENTER);
    
}else {
    System.out.println("Row " + i + " does not exist in the Excel sheet.");
}
}
    

Im 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 then I click the SigIn button the test getting closes when i add (driver.quit)./ else the test stops there without signing In.`

1

There are 1 answers

0
MVS KRISHNA On

Can you pls try with the below for the Sign In Button ?

driver.findElement(By.xpath("//div[@class='inline-block button-item ext-button-item']//input[@value='Sign in']")).click();

It worked for me.