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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Milan Joshi
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);

}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cbec0662-9d43-4f4f-b95b-7532781d0925%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Anda Cristea
try to use

 driver.switchTo().activeElement();
   WebElement btnDeleteTrashEmails = driver.findElement(By
     .className("btn left right default"));





On Sunday, May 28, 2017 at 7:57:54 AM UTC+3, Milan Joshi wrote:
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.

<a onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F44218772%2Fhow-to-handle-javascript-pop-up-seems-like-an-alert-window-redirecting-towards\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF85FbPXevSrx_O6L1OTDBJYD670Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F44218772%2Fhow-to-handle-javascript-pop-up-seems-like-an-alert-window-redirecting-towards\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF85FbPXevSrx_O6L1OTDBJYD670Q&#39;;return true;" href="https://stackoverflow.com/questions/44218772/how-to-handle-javascript-pop-up-seems-like-an-alert-window-redirecting-towards" target="_blank" rel="nofollow">https://stackoverflow.com/questions/44218772/how-to-handle-javascript-pop-up-seems-like-an-alert-window-redirecting-towards

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);

}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/93e92a6d-8b1b-41aa-b9e3-4f4a8d89f134%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...