I have java code for one of my automation website and I copy that code to other PC to run other Website however the first step is running ok which is open the URL but the rest can not be run , unable to locate the element id , here is the code in Java:
@When("^I enter (.*) in the (.*)$")
public void i_enter_in_the_Username_txt_box(String emailaddress,String boxname) throws Throwable {
WebDriverWait wait = new WebDriverWait(driver,LOAD);
By id = By.id(boxname);
wait.until(ExpectedConditions.elementToBeClickable(id));
driver.findElement(By.id(boxname)).sendKeys(emailaddress);
}
BDD for this code is :
Feature: XYZ
Scenario: Add valid username and password then click on login button
Given User at login page // this one is working fine
When I enter Admin in the username // this one is not working , error saying that the Id for the username field can not find
And I enter Admin in the password
Then Home page will display
Would you please let me now if you know where is the issue ? I tried the following but still i got the error :
- Add Thread.sleep(1000); to wait but still i got the error
- I added "" for the Admin and the Id for the field in the BDD file but still it did not work
I am using cucumber , Firefox , selenium , Eclipse , BDD, Maven and Java Thanks a lot