how to handle javascript pop up :seems like an alert window redirecting towards a url

45 views
Skip to first unread message

Milan Joshi

unread,
May 28, 2017, 12:57:54 AM5/28/17
to Selenium Users
Hi,

Please help , i have to access a javascript pop up window that redirects to a url and having form fields within it.
It does not contain min/max button. and nothing works until this window is not closed or filled and updated.


in the code below you can see two red highlights : 

1: click on the link >> thus javascript window opens
2: i tried to close that window ......................................nothing works yet...


  @Test(priority=9)
public void PurchaseUpload_activevendor() throws Exception 
{
System.out.println("CheckPurchasesubmenupages  started");
UIMap(datafilefilepath);
driver.get(getData("url"));
verifyHomepageTitle("Dnet");
lp.Login(getData("username"),getData("password"));
//Assert.assertTrue(false);
  
System.out.println(driver.getWindowHandle());
hp.frame_top();
myWait.until(ExpectedConditions.elementToBeClickable(hp.clickPurchaseaggrmnt));
   
pa.Handlesubcategorylinks();
   
System.out.println("about to click");
//pa.tabularname().click();
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", pa.tabularname());
Thread.sleep(6);
                       String script = "window.onbeforeunload = null;" + "window.close();";
        js.executeScript(script);

}

Anda Cristea

unread,
Jun 4, 2017, 10:42:27 PM6/4/17
to Selenium Users
try to use

 driver.switchTo().activeElement();
   WebElement btnDeleteTrashEmails = driver.findElement(By
     .className("btn left right default"));
Reply all
Reply to author
Forward
0 new messages