0

Before I begin, I've tried...

Selenium Htmlunit org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements

Error:org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements using htmlunitdriver?

Selenium HtmlUnitDriver clicking on checkbox

None of these work for me...

I have narrowed down my issue to the username.sendKeys("hullo"); line

 import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class WebAccessor  {
    public static void main(String[] args) {

        WebDriver driver = new HtmlUnitDriver();
        driver.get("https://portal.mcpsmd.org/public/");

        // Find the text input element by its name
        WebElement username = driver.findElement(By.id("fieldAccount"));
        WebElement password = driver.findElement(By.id("fieldPassword"));

        // Enter something to search for
        username.sendKeys("hullo");

//      WebElement submit = driver.findElement(By.name("btn-enter"));

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        driver.quit();
    }
}

Now, unfortunately, nothing i have tried allows me to fix the "you may only interact with visible elements" error and, from what I have seen, this field is QUITE visible, it is labeled correctly from what an hour of digging in the inspect element field.

Many thanks in advance.

DucksEatTurtles
  • 194
  • 1
  • 2
  • 10

2 Answers2

0

Try to check what this returns

 element.is_displayed()

If its False, then the possible reason is in the dom the display is set to none, hence restricting you from inputting anything.

Sajid Manzoor
  • 487
  • 1
  • 5
  • 9
-1

When i tried to run the code I am not getting any exception :

I have used dependency :

<dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-htmlunit-driver</artifactId>
            <version>2.52.0</version>
        </dependency>

It is printing the text : "Page title is: Student and Parent Sign In"

You should change your maven dependency.

Hope that helps.

dangi13
  • 1,275
  • 1
  • 8
  • 11
  • Found the issue, I had used the eclipse automatic dependency adding solution and it gave me an outdated version of selenium, Thanks for your help! – DucksEatTurtles Jun 21 '18 at 15:14