1

I am trying to the test an angularJs Frontend by using Selenium Webdriver with Java.

I would likte to send some keys to an email inputbox. The problem I am facing is, that the inputbox seems to be invisivile for selenium. I guess this has something to do with the ng-hide directive from angular. To be clear, I can defenitly see the inputbox when the testautomation starts, so for me as a person the inputbox seems to be visible.

Frontend Image:

enter image description here

HTML:

<input id="changedbyEmailInput" class="form-control ng-pristine ng-valid ng-empty ng-touched" type="text" ng-model="article.author.email" placeholder="Your Email" ng-hide="article.isTemp === false" style="">

Javacode to get the textbox:

element = driver.findElement(By.id("changedbyEmailInput"));
element.sendKeys(keys);

Javacode with Timeout

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("changedbyEmailInput")));

I also tried to use an timout but it just timeouts, so I guess it just never changes it's state.

PS: If someone knows if this issue is easy to solve by using protractor please let me know. I am open to switch to protractor if it will solve my problem.

Thank you!

Edit: The problem is solved. It has nothing to do with ng-hide. The id just wasn't uniqe. Therefore there was always one disabled inputbox.

2
  • 2
    Have you checked that the id is unique and not in a frame? Do you get a result by executing document.querySelectorAll("[id='changedbyEmailInput']") in the browser's console? Commented Jun 6, 2016 at 11:03
  • I found the issue. You were right, this id is not unique... So there is always one enabled inputbox and one disabled. Commented Jun 6, 2016 at 11:24

1 Answer 1

1

You should try JavascriptExecutor to set value as follows :-

JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById('changedbyEmailInput').value = arguments[0]", "value to set");

Hope it will help you...:)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.