NoAlertPresentException: No modal dialog is currently open | Selenium Forum
M
Posted on 07/06/2018
[b:1zga3ia3]I am struggling for last two days click on 'Create Portfolio' button which opens Dialog Box. [/b:1zga3ia3]

[b:1zga3ia3]screenshots are provided[/b:1zga3ia3]

Please help me to find out correct approach, i can't move ahead by skipping this.

[b:1zga3ia3] I have tried multiple approach but it doesn't worked[/b:1zga3ia3]

1 WebElement button =driver.findElement(By.xpath("//div[@class='lft']/ul/li[3]/a"));
Point location = button.getLocation();
Actions act = new Actions(driver);
int x= location.getX();
int y=location.getY();
act.moveToElement(button,x,y).click().build().perform();

2 JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement button =driver.findElement(By.xpath("/html/body/div[3]/div[2]/div/div[1]/div/div[4]/div[2]/ul[@class='editPort']/li[3]/a/img[@title='Create']"));
js.executeScript("arguments[0].click();", button);

3 WebDriverWait wait1 =new WebDriverWait(driver, 30);
wait1.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//ul[@class='editPort']/li[3]/a"))));
driver.findElement(By.xpath("//ul[@class='editPort']/li[3]/a")).click();


above any approach gives below error
org.openqa.selenium.NoAlertPresentException: No modal dialog is currently open

M
Replied on 08/06/2018

Did you try using chrome browser?

Additionally, i noticed that firefox is showing up a alert box.
To handle that you need to use the below code.

[code:20kpv19m]WebDriverWait explicitWait = new WebDriverWait(driver, 5);
explicitWait.until(ExpectedConditions.alertIsPresent());
Alert alertingHandler = driver.switchTo().alert();
alertingHandler.accept();
driver.switchTo().defaultContent();[/code:20kpv19m]


M
Replied on 13/06/2018

Hello,

It's working for home.


M
Replied on 14/06/2018

This code absolutely works fine
[code:3h4xon1i]import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class RediffPortfolio {
public static void main(String[] args) throws Exception {


WebDriver driver = new FirefoxDriver();

/************************* Chrome Browser *******************************/
// WebDriver driver = new ChromeDriver();
/************************* Common Code ***********************************/
driver.get("https://portfolio.rediff.com/portfolio");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// Logging in
driver.findElement(By.cssSelector("#useremail")).sendKeys("xxxxx");
driver.findElement(By.cssSelector("#emailsubmit")).click();

driver.findElement(By.cssSelector("#userpass")).sendKeys("xxxxx");
driver.findElement(By.cssSelector("#loginsubmit")).click();
/* Specific to FireFox only. */
WebDriverWait explicitWait = new WebDriverWait(driver, 5);
explicitWait.until(ExpectedConditions.alertIsPresent());
Alert al = driver.switchTo().alert();
al.accept();
driver.switchTo().defaultContent();

// Creating PortFolio
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@id='createPortfolio']")).click();
driver.findElement(By.cssSelector("#create")).sendKeys("newDummyPortfolio");
driver.findElement(By.cssSelector("#createPortfolioButton")).click();
}
}[/code:3h4xon1i]


M
Replied on 18/06/2018

Instead of alert you can also wait for page to load
In module 17, we have taken this as an exercise