0

Code trials:

import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Mftadminui {

    public static void main(String[] args) {`
        System.setProperty("webdriver.edge.driver", "C:\\Users\\shantha_mh\\Desktop\\SeleniumAutomation\\msedgedriver.exe");
        WebDriver driver = new EdgeDriver();
        driver.get("https://test.idp.idm.cms.gov/");
        driver.findElement(By.id("okta-signin-username")).sendKeys("HNAJ");
        driver.findElement(By.name("password")).sendKeys("Hs229988");
        driver.findElement(By.cssSelector("input[id='tandc']")).click();
        System.out.println(driver.findElement(By.cssSelector("input[id='tandc']")).isSelected());
        driver.findElement(By.className("button-primary")).click();
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[@class='o-form-input-name-answer o-form-control okta-form-input-field input-fix']")));
        WebElement mfaInput = driver.findElement(By.xpath("//span[@class='o-form-input-name-answer o-form-control okta-form-input-field input-fix']"));
        String userInput = mfaInput.getAttribute("value");
        driver.findElement(By.xpath("//span[@class='o-form-input-name-answer o-form-control okta-form-input-field input-fix']")).click();
        mfaInput.sendKeys(" ");
        driver.findElement(By.id("input76")).click();

I was trying to automate the MFA User input, code reaches till the MFA input page and getting the following error:

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable.

Exploring one of the previous posts, but I couldn't figure out what the problem was in this code. Please assist me.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

Not that super clear at which step you are stuck. However to send a character sequence to the <input> fields you can use either of the following Locator Strategies:

driver.get("https://test.idp.idm.cms.gov/");
new WebDriverWait(driver, Duration.ofSeconds(5)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#okta-signin-username"))).sendKeys("HNAJ");
driver.findElement(By.cssSelector("input#okta-signin-password")).sendKeys("Hs229988");
driver.findElement(By.cssSelector("input[title='Agree to terms and conditions']")).click();
driver.findElement(By.cssSelector("input#okta-signin-submit")).click();

Browser Snapshot:

GoogleAuthenticator

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Expecting the code to wait until the user Enter Google Authenticator Code and click on Verify as I have last line of code. The code starting from WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30)); is written for this purpose. – user18815229 Jan 20 '23 at 13:50
  • You expect StackOverflow volunteer contributors to install Google Authenticator to solve this question? – undetected Selenium Jan 20 '23 at 14:15
  • While reviewing the log (I don't know how to attach it here on stack overflow), I see that the Exception in thread "main" element not interactable error using Selenium Java with Edge WebDriver points to the last line of code in my shared code. There is something missing for the wait to not working to process after I input the MFA code. – user18815229 Jan 20 '23 at 14:51
  • @user18815229 Ideally I should have closed this question as you haven't supplied the text based relevant HTML. Please update the question accordingly. – undetected Selenium Jan 20 '23 at 15:06