2

When I try to click an element hosted inside of a dialog is returning NoSuch element exeption

error returned

I've tried using active element and also switch to default content but no success. This portion of code has no iframes in the middle so a line that switchto an iframe is not needed

Here is the code:

public void editarDatosContacto(String contacto, String canal){
        openEditarContacto(botonAgregarCel());
        waitDefaultTime();
        getDriver().switchTo().parentFrame();
        getDriver().switchTo().parentFrame();
        WebDriverWait block = new WebDriverWait(getDriver(),10);
        block.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"midialogBpf01\"]/div/object")));
        WebElement modal = getDriver().findElement(By.xpath("//*[@id=\"midialogBpf01\"]/div/object"));
        WebElement item;
        item = modal.findElement(By.xpath("//div[@class='row']/div/div/div[1]/div/div//a[@data-toggle='modal']"));
        item.click();
        Select selectDato = new Select(selectTipo());
        selectDato.selectByVisibleText(contacto);

}

The line that is not finding the element is this:

item = modal.findElement(By.xpath("//div[@class='row']/div/div/div[1]/div/div//a[@data-toggle='modal']"));

And this is the application html code to find the element

The app is only accessed through a vpn so I can't share it.

  • I don't think this is related to the `dynamics-crm` tag. You should probably retag your question to get better results – jasonscript Sep 16 '19 at 03:44

1 Answers1

1

Solution find!

I had to switch to modal first like this

WebElement modal = getDriver().findElement(By.xpath("//*[@id=\"midialogBpf01\"]/div/object"));
WebElement item;
driver.switchTo.frame(modal);
item = getDriver().findElement(By.xpath("//div[@class='row']/div/div/div[1]/div/div//a[@data-toggle='modal']"));
item.click();

So that was the fix.

I hope this help someone with same issue.

Thanks