Home > other >  Selenium not able to input element in the form inside fieldset tag
Selenium not able to input element in the form inside fieldset tag

Time:10-25

I have tried a different method to input elements like Here is xpath I used

By NameOfTheProperty=By.xpath("//fieldset/div/input[@name='name']");
By NameOfTheProperty=By.xpath("//div/input[@name='name']");
By NameOfTheProperty=By.xpath("//input[@name='name']");

Tried with Selenium Builder

 WebElement element=driver.findElement(by);
        Actions builder = new Actions(driver);
        Action mouseOverHome = builder
                .moveToElement(element)
                .click().sendKeys(text).build();
        mouseOverHome.perform();

Tried with

 WebElement element=driver.findElement(by);
        element.sendKeys(text);

None of the methods is working..I can not able to input text inside the field and It shows

Element not interactable

Here is the site

enter image description here

I hope someone help me to find out the solution..

CodePudding user response:

Please check in the dev tools (Google chrome) if we have unique entry in HTML DOM or not.

Steps to check:

Press F12 in Chrome -> go to element section -> do a CTRL F -> then paste the xpath and see, if your desired element is getting highlighted with 1/1 matching node.

xpath you should checks is :

//input[@name='name']

if it is unique, then you can use Javascript executor :

WebElement password_input = driver.findElemenet(By.xpath("//input[@name='name']"));
((JavascriptExecutor) driver).executeScript("arguments[0].setAttribute('value', 'password_should_be_written_here')", password_input)

CodePudding user response:

personally I would use id's if the element has one.

"//*[@id='__BVID__104']"

Make sure you are waiting for the element to be ready.

WebDriverWait wait = new WebDriverWait();
wait.until(ExpectedConditions.elementToBeClickable(element));

If it then times out on wait.until(... then I've found that sometimes an element must first be clicked for it to be exposed.

If this is the case. You will have to inspect the element before it is clicked. Find it's xpath, and see if it changes when it is clicked. If so then create a webElement for that element and have Selenium first click it, before clicking the actual field/element.

  • Related