You have inside the iframe. So in Selenium, to work with element which is in embedded resource such as frame, you need to first switch into respective iframe and then perform the actions.

There are following ways to switch into frame :

  1. Switch to the frame by index :

    driver.switchTo().frame(0);
    
  2. Switch to the frame by Name or ID attributes :

    e.g. <frame src="http://52.24.63.155/lifepal/AdminPanel" name="adminPanel" id="some_id">

    driver.switchTo().frame("adminPanel");
    driver.switchTo().frame("some_id");
    
  3. Switch to the frame by Web Element

    WebElement frame = driver.findElement(By.locator);
    
    driver.switchTo().frame(frame); 
    
  4. You can use ExplicitWait as well :

    new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[contains(@src,'http://52.24.63.155/lifepal/AdminPanel')]")));
    

And then perform the action. In Page Factory fashion your element would be :

@FindBy(id="input_001")
private WebElement username;

public WebElement getUsername(){
    return username;
}

public void sendUsername(String uname){
    getUsername().sendKeys(uname);
}



Source link https://sqa.stackexchange.com/questions/35321/how-to--no-such-element-

LEAVE A REPLY

Please enter your comment!
Please enter your name here