0

I'm new in this forum and this is actually my first time ever coding

in the code i have this part:

md-input-container class="md-default-theme md-input-invalid">
label for="input_4">Email</label>
input name="emailField" type="email" ng-model="email" ng-change="resetValidity()" auto-focus="" validate-email="" required="" class="ng-pristine md-input ng-valid-email ng-invalid ng-invalid-required ng-touched" id="input_4" tabindex="0" aria-required="true" aria-invalid="true" style="">
!-- ngIf: forgot_password.emailField.$invalid && forgot_password.$submitted -->
/md-input-container>

the ID everytime i open a session get a different number. i try this:

WebElement emailField = driver.findElement(By.cssSelector("input[name='emailField']"));
emailField.click();
emailField.sendKeys("aa@aa");

can be reach also in the URL: "ocloud.optitex.com" go to "forgot password" i'm trying to find the email field there , click on it and send keys

but nothing happen. i get this error:

No such Element Exception , unable to locate element.

will appreciate any help regarding how i can click on the field and send keys.

7
  • is your element in iframe ? Commented May 15, 2017 at 10:21
  • nop. not in iframe. - i forgot to add one line to the code- editing. Commented May 15, 2017 at 10:24
  • can you try this WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@name='emailField']"))); driver.findElement(By.xpath("//input[@name='emailField']")).sendKeys("[email protected]"); and let me know any issue Commented May 15, 2017 at 10:39
  • @N.P Did the Answers solve your Question? Let me know the status. Thanks Commented May 15, 2017 at 10:44
  • @narendra-rajput I got the same result , no such element exception ,Unable to locate element Commented May 15, 2017 at 10:52

2 Answers 2

1

Use Implicit wait in your code to give sufficient time to locate the element before it through exception

driver = new ChromeDriver();    
driver.manage().window().maximize();
driver.get("https://ocloud.optitex.com/#/login/");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.xpath("//button/span[contains(.,'Forgot Password?')]")).click();
driver.findElement(By.xpath("//input[@name='emailField']")).sendKeys("[email protected]");
driver.findElement(By.xpath("//button/span[contains(.,'Reset Password')]")).click();
Sign up to request clarification or add additional context in comments.

2 Comments

no the F wasn't the problem . same result. - but i will edit my question with the "F".
@N.P , Use updated code , same is working fine at my end
0

Use xpath;

WebElement emailField = driver.findElement(By.xPath("//input[@name='emailField']"));
emailField.click();
emailField.sendKeys("aa@aa");

4 Comments

i got the same result , no such element exception ,Unable to locate element
Okay, can you try this xpath? "//md-input-container/input"
got this now: unknown error: Element <input type="email" ng-model="cf.email" auto-focus="" required="" class="ng-pristine md-input ng-valid-email ng-invalid ng-invalid-required ng-touched" id="input_0" tabindex="0" aria-required="true" aria-invalid="true" style=""> is not clickable at point (978, 435). Other element would receive the click: <md-input-container class="md-default-theme md-input-focused">...</md-input-container>
Can you edit your question with more source html code or url?

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.