Hello Selenium Experts,

I am having trouble closing the new browser pop up which appears after
clicking the button. I am able to open a new window and switch to the main
window but not able to close the main window.

When i say driver.close() after swithcing to new window, it closes the main
window and fails the test.

Can anyone experience this problem?

If yes, can you please help me find the solution.

Any help would be appreciated.


Below is the webdriver code that I have.


* public void Test1()*
* {*
* Methods Common = new Methods(driver); //calls the common class*
* *
* string originalHandle= driver.CurrentWindowHandle; //gets
the current window handle*
* driver.FindElement(By.LinkText("Developer")).Click();*
* *
* if
(Common.IsElementPresent(By.CssSelector("a[class='app12']")))*
* {*
* Common.waitforElement(By.CssSelector("a[class='app12']"));*
*
driver.FindElement(By.CssSelector("a[class='app12']")).Click();*
* }*
* *
* else if
(Common.IsElementPresent(By.CssSelector("div[class='bicon']")))*
* {*
*
driver.FindElement(By.CssSelector("div[class='bicon']")).Click(); //opens
a new browser window after clicking the button*
* }*
* *
*
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));*
* driver.Close(); //closes the main window instead of popup and
fails.*
* driver.SwitchTo().Window(originalHandle);*
*
Common.waitforElement(By.CssSelector("button[class='success']"));*
* *
* }*


Thanks,

Sirus

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ashok Tulachan at Sep 21, 2012 at 5:08 pm
    Correction: I mean to say i'm not able to close the new browser pop up
    window.

    Thanks,

    Sirus.
    On Fri, Sep 21, 2012 at 12:00 PM, sirus tula wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if
    (Common.IsElementPresent(By.CssSelector("a[class='app12']")))*
    * {*
    *
    Common.waitforElement(By.CssSelector("a[class='app12']"));*
    *
    driver.FindElement(By.CssSelector("a[class='app12']")).Click();*
    * }*
    * *
    * else if
    (Common.IsElementPresent(By.CssSelector("div[class='bicon']")))*
    * {*
    *
    driver.FindElement(By.CssSelector("div[class='bicon']")).Click(); //opens
    a new browser window after clicking the button*
    * }*
    * *
    *
    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
    *
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    *
    Common.waitforElement(By.CssSelector("button[class='success']"));*
    * *
    * }*


    Thanks,

    Sirus

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.



    --
    Regards,

    Ashok Tulachan

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Neeraj Sharma at Sep 21, 2012 at 5:09 pm
    Yes, this is because you are closing the driver before switching to the new
    window, see your code,
    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if
    (Common.IsElementPresent(By.CssSelector("a[class='app12']")))*
    * {*
    *
    Common.waitforElement(By.CssSelector("a[class='app12']"));*
    *
    driver.FindElement(By.CssSelector("a[class='app12']")).Click();*
    * }*
    * *
    * else if
    (Common.IsElementPresent(By.CssSelector("div[class='bicon']")))*
    * {*
    *
    driver.FindElement(By.CssSelector("div[class='bicon']")).Click(); //opens
    a new browser window after clicking the button*
    * }*
    * *
    *
    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
    *
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    *
    Common.waitforElement(By.CssSelector("button[class='success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Sirus tula at Sep 21, 2012 at 5:13 pm
    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following code but
    the driver is still picking up the main window instead of new window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main window*

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));*

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching to the
    new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.
    CssSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSelector("a[class='app12']"
    ));*
    * driver.FindElement(By.CssSelector("a[class='app12']"
    )).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.
    CssSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelector("div[class='bicon']")).Click();
    //opens a new browser window after clicking the button*
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Sirus tula at Sep 21, 2012 at 5:14 pm
    Correction, seeker=driver.

    Thanks :)
    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula wrote:

    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following code
    but the driver is still picking up the main window instead of new window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main window
    *

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
    *

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching to the
    new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.
    CssSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSelector("a[class='app12']"
    ));*
    * driver.FindElement(By.CssSelector("a[class='app12']"
    )).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.
    CssSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelector("div[class='bicon']")).Click();
    //opens a new browser window after clicking the button*
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Neeraj Sharma at Sep 21, 2012 at 5:21 pm
    read this thread and might be you are able to find your solution, i have
    already posted a working demo code there for dealing with multiple windows.
    https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/BGBFNmWaeLg

    On Friday, 21 September 2012 22:44:07 UTC+5:30, sirus wrote:

    Correction, seeker=driver.

    Thanks :)

    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula <selenium...@gmail.com<javascript:>
    wrote:
    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following code
    but the driver is still picking up the main window instead of new window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main
    window*

    *driver.Close();*

    *
    drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
    *

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus

    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma <mintu...@gmail.com<javascript:>
    wrote:
    Yes, this is because you are closing the driver before switching to the
    new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.
    CssSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.
    CssSelector("a[class='app12']"));*
    * driver.FindElement(By.CssSelector("a[class='app12']"
    )).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.
    CssSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelector("div[class='bicon']")).Click();
    //opens a new browser window after clicking the button*
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of
    popup and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/WP7EC02AW54J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Sirus tula at Sep 21, 2012 at 5:36 pm
    Thanks Niraj, NOT sure how it would help on this issue though.

    Seems like this is webdriver defect although I found out the work around
    solution.

    *String newWindow= driver.CurrentWindowHandle; //still refers to the main
    window not sure why.*

    However, here's the work around solution that i found.

    *driver.SwitchTo().Window(driver.WindowHandles.ToList().Last()); //
    switches to the new window
    *
    *driver.close(); // Now closes the new window
    *


    Thanks,

    Sirus
    On Fri, Sep 21, 2012 at 12:21 PM, Neeraj Sharma wrote:

    read this thread and might be you are able to find your solution, i have
    already posted a working demo code there for dealing with multiple windows.

    https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/BGBFNmWaeLg


    On Friday, 21 September 2012 22:44:07 UTC+5:30, sirus wrote:

    Correction, seeker=driver.

    Thanks :)
    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula wrote:

    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following code
    but the driver is still picking up the main window instead of new window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main
    window*

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching to
    the new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.Cs
    sSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSe
    lector("a[class='app12']"));*
    * driver.FindElement(By.CssSelector("a[class='app12']"
    )).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.Cs
    sSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelector("div[class='bicon'
    ]")).Click(); //opens a new browser window after clicking the button*
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of
    popup and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/zBdHmdPD_**IcJ<https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ>.


    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/WP7EC02AW54J.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Neeraj Sharma at Sep 21, 2012 at 5:34 pm
    your problem is same as first of all you are not able to switch to the new
    window. and if this problem is solved then you can proceed further so first
    try to solve this problem. Can you please give me any URL related to your
    application so that i can show you the same code for that to deal with the
    windows.
    On Friday, 21 September 2012 22:57:22 UTC+5:30, sirus wrote:

    Thanks Niraj, NOT sure how it would help on this issue though.

    Seems like this is webdriver defect although I found out the work around
    solution.

    *String newWindow= driver.CurrentWindowHandle; //still refers to the main
    window not sure why.*

    However, here's the work around solution that i found.

    *driver.SwitchTo().Window(driver.WindowHandles.ToList().Last()); //
    switches to the new window
    *
    *driver.close(); // Now closes the new window
    *


    Thanks,

    Sirus
    On Fri, Sep 21, 2012 at 12:21 PM, Neeraj Sharma <mintu...@gmail.com<javascript:>
    wrote:
    read this thread and might be you are able to find your solution, i have
    already posted a working demo code there for dealing with multiple windows.

    https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/BGBFNmWaeLg


    On Friday, 21 September 2012 22:44:07 UTC+5:30, sirus wrote:

    Correction, seeker=driver.

    Thanks :)
    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula wrote:

    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following code
    but the driver is still picking up the main window instead of new window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main
    window*

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching to
    the new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears
    after clicking the button. I am able to open a new window and switch to the
    main window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes
    the main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the
    common class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.Cs
    sSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSe
    lector("a[class='app12']"));*
    * driver.FindElement(By.CssSelector("a[class='app12']"
    )).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.Cs
    sSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelector("div[class='bicon'
    ]")).Click(); //opens a new browser window after clicking the button
    *
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of
    popup and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/*
    *msg/selenium-users/-/zBdHmdPD_**IcJ<https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ>.


    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/WP7EC02AW54J.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/njv-MgcuwXUJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jim Evans at Sep 21, 2012 at 5:35 pm
    WebDriver does not automatically switch to new windows when opened. You
    have to do that yourself, so it's not surprising (nor is it a bug) that the
    .CurrentWindowHandle property would still refer to the main window, even
    though you've clicked on the link to open a new window. Notice also that
    the list of window handles returned by the .WindowHandles property is not
    guaranteed to be in any order. That means you cannot rely on the last
    handle in the list being the last window opened.

    In the .NET support classes (WebDriver.Support.dll) there is a
    PopupWindowFinder class that provides an example of how to properly
    implement this behavior. You're welcome to use the class as-is, but it's
    intended to be an example, so if it doesn't meet your needs 100%, you'll
    need to implement your own version.
    On Friday, September 21, 2012 10:27:22 AM UTC-7, sirus wrote:

    Thanks Niraj, NOT sure how it would help on this issue though.

    Seems like this is webdriver defect although I found out the work around
    solution.

    *String newWindow= driver.CurrentWindowHandle; //still refers to the main
    window not sure why.*

    However, here's the work around solution that i found.

    *driver.SwitchTo().Window(driver.WindowHandles.ToList().Last()); //
    switches to the new window
    *
    *driver.close(); // Now closes the new window
    *


    Thanks,

    Sirus
    On Fri, Sep 21, 2012 at 12:21 PM, Neeraj Sharma <mintu...@gmail.com<javascript:>
    wrote:
    read this thread and might be you are able to find your solution, i have
    already posted a working demo code there for dealing with multiple windows.

    https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/BGBFNmWaeLg


    On Friday, 21 September 2012 22:44:07 UTC+5:30, sirus wrote:

    Correction, seeker=driver.

    Thanks :)
    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula wrote:

    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following code
    but the driver is still picking up the main window instead of new window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main
    window*

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching to
    the new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears
    after clicking the button. I am able to open a new window and switch to the
    main window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes
    the main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the
    common class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.Cs
    sSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSe
    lector("a[class='app12']"));*
    * driver.FindElement(By.CssSelector("a[class='app12']"
    )).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.Cs
    sSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelector("div[class='bicon'
    ]")).Click(); //opens a new browser window after clicking the button
    *
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of
    popup and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/*
    *msg/selenium-users/-/zBdHmdPD_**IcJ<https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ>.


    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/WP7EC02AW54J.

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/JFOeQsKM8WgJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ashok Tulachan at Sep 21, 2012 at 5:46 pm
    Thank u Jim again. Not sure how many times we have exchanged emails :).

    It's very hard to find help on webdriver c# problems since many people use
    java and there are only handful of webdriver c# experts like u :).

    Thanks again :).
    On Sep 21, 2012 12:35 PM, "Jim Evans" wrote:

    WebDriver does not automatically switch to new windows when opened. You
    have to do that yourself, so it's not surprising (nor is it a bug) that the
    .CurrentWindowHandle property would still refer to the main window, even
    though you've clicked on the link to open a new window. Notice also that
    the list of window handles returned by the .WindowHandles property is not
    guaranteed to be in any order. That means you cannot rely on the last
    handle in the list being the last window opened.

    In the .NET support classes (WebDriver.Support.dll) there is a
    PopupWindowFinder class that provides an example of how to properly
    implement this behavior. You're welcome to use the class as-is, but it's
    intended to be an example, so if it doesn't meet your needs 100%, you'll
    need to implement your own version.
    On Friday, September 21, 2012 10:27:22 AM UTC-7, sirus wrote:

    Thanks Niraj, NOT sure how it would help on this issue though.

    Seems like this is webdriver defect although I found out the work around
    solution.

    *String newWindow= driver.CurrentWindowHandle; //still refers to the
    main window not sure why.*

    However, here's the work around solution that i found.

    *driver.SwitchTo().Window(driver.WindowHandles.ToList().Last()); //
    switches to the new window
    *
    *driver.close(); // Now closes the new window
    *


    Thanks,

    Sirus
    On Fri, Sep 21, 2012 at 12:21 PM, Neeraj Sharma wrote:

    read this thread and might be you are able to find your solution, i have
    already posted a working demo code there for dealing with multiple windows.
    https://groups.google.com/**forum/?fromgroups=#!topic/**
    selenium-users/BGBFNmWaeLg<https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/BGBFNmWaeLg>


    On Friday, 21 September 2012 22:44:07 UTC+5:30, sirus wrote:

    Correction, seeker=driver.

    Thanks :)
    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula wrote:

    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following
    code but the driver is still picking up the main window instead of new
    window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main
    window*

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMillis
    econds(500));*

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching to
    the new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears
    after clicking the button. I am able to open a new window and switch to the
    main window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes
    the main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the
    common class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.Cs
    sSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSe
    lector("a[class='app12']"));*
    * driver.FindElement(By.CssSelec
    tor("a[class='app12']")).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.Cs
    sSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelec
    tor("div[class='bicon']")).Click(); //opens a new browser window
    after clicking the button*
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of
    popup and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.**com.
    To view this discussion on the web visit https://groups.google.com/d/
    **ms**g/selenium-users/-/zBdHmdPD_**Ic**J<https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ>.


    For more options, visit https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/**WP7EC02AW54J<https://groups.google.com/d/msg/selenium-users/-/WP7EC02AW54J>.


    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/JFOeQsKM8WgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Asiq Ahamed at May 22, 2013 at 5:22 am
    Why don't you try Robotil?, it is a simple library to press/release
    keyboard keys, invoke application, take screenshot on a remote machine and
    send a file to a computer.

    http://www.codoid.com/products/view/2/27
    On Friday, September 21, 2012 11:16:52 PM UTC+5:30, Ash wrote:

    Thank u Jim again. Not sure how many times we have exchanged emails :).

    It's very hard to find help on webdriver c# problems since many people use
    java and there are only handful of webdriver c# experts like u :).

    Thanks again :).
    On Sep 21, 2012 12:35 PM, "Jim Evans" <james.h....@gmail.com <javascript:>>
    wrote:
    WebDriver does not automatically switch to new windows when opened. You
    have to do that yourself, so it's not surprising (nor is it a bug) that the
    .CurrentWindowHandle property would still refer to the main window, even
    though you've clicked on the link to open a new window. Notice also that
    the list of window handles returned by the .WindowHandles property is not
    guaranteed to be in any order. That means you cannot rely on the last
    handle in the list being the last window opened.

    In the .NET support classes (WebDriver.Support.dll) there is a
    PopupWindowFinder class that provides an example of how to properly
    implement this behavior. You're welcome to use the class as-is, but it's
    intended to be an example, so if it doesn't meet your needs 100%, you'll
    need to implement your own version.
    On Friday, September 21, 2012 10:27:22 AM UTC-7, sirus wrote:

    Thanks Niraj, NOT sure how it would help on this issue though.

    Seems like this is webdriver defect although I found out the work around
    solution.

    *String newWindow= driver.CurrentWindowHandle; //still refers to the
    main window not sure why.*

    However, here's the work around solution that i found.

    *driver.SwitchTo().Window(driver.WindowHandles.ToList().Last()); //
    switches to the new window
    *
    *driver.close(); // Now closes the new window
    *


    Thanks,

    Sirus
    On Fri, Sep 21, 2012 at 12:21 PM, Neeraj Sharma wrote:

    read this thread and might be you are able to find your solution, i
    have already posted a working demo code there for dealing with multiple
    windows.
    https://groups.google.com/**forum/?fromgroups=#!topic/**
    selenium-users/BGBFNmWaeLg<https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/BGBFNmWaeLg>


    On Friday, 21 September 2012 22:44:07 UTC+5:30, sirus wrote:

    Correction, seeker=driver.

    Thanks :)
    On Fri, Sep 21, 2012 at 12:13 PM, sirus tula wrote:

    * *
    Thank you for your prompt response, Niraj.

    After the new pop up window is displayed, I also use the following
    code but the driver is still picking up the main window instead of new
    window.

    *string newWindow = seeker.CurrentWindowHandle;*

    *driver.SwitchTo().Window(newWindow); // it still selects the main
    window*

    *driver.Close();*

    *drivr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMillis
    econds(500));*

    *driver.SwitchTo().Window(originalHandle);*
    Thanks

    Sirus
    On Fri, Sep 21, 2012 at 12:09 PM, Neeraj Sharma wrote:

    Yes, this is because you are closing the driver before switching
    to the new window, see your code,

    On Friday, 21 September 2012 22:30:39 UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears
    after clicking the button. I am able to open a new window and switch to the
    main window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes
    the main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the
    common class*
    * *
    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*
    * *
    * if (Common.IsElementPresent(By.Cs
    sSelector("a[class='app12']")))*
    * {*
    * Common.waitforElement(By.CssSe
    lector("a[class='app12']"));*
    * driver.FindElement(By.CssSelec
    tor("a[class='app12']")).Click();*
    * }*
    * *
    * else if (Common.IsElementPresent(By.Cs
    sSelector("div[class='bicon']")))*
    * {*
    * driver.FindElement(By.CssSelec
    tor("div[class='bicon']")).Click(); //opens a new browser window
    after clicking the button*
    * }*
    * *
    * driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.
    FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of
    popup and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    * Common.waitforElement(By.CssSelector("button[class='
    success']"));*
    * *
    * }*


    Thanks,

    Sirus
    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.**com.
    To view this discussion on the web visit
    https://groups.google.com/d/**ms**g/selenium-users/-/zBdHmdPD_**Ic**
    J <https://groups.google.com/d/msg/selenium-users/-/zBdHmdPD_IcJ>.

    For more options, visit https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google
    Groups "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.**com.
    To unsubscribe from this group, send email to selenium-user...@**
    googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/**
    msg/selenium-users/-/**WP7EC02AW54J<https://groups.google.com/d/msg/selenium-users/-/WP7EC02AW54J>.


    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to seleniu...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    selenium-user...@googlegroups.com <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/JFOeQsKM8WgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    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 selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/d4097057-7a84-4b35-b569-117c2282d0e6%40googlegroups.com?hl=en-US.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Sat at Feb 28, 2014 at 4:45 pm
    Hi all,

    What is the best way to close the browsers after each run *(Especially
    Firefox )*.

    I am getting below error (If I forget to close my FF Browser manually
    ,before run the each test )

    Any idea from your side?

    To avoid the issue ,I have to close the the browser manually ,before run
    the each test .

    Thanks,
    SAT

    ==============================
    ========================================================================================================

    org.testng.TestNGException:
    Cannot instantiate class UserManagement.UserTest
         at
    org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
         at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
         at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
         at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
         at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
         at
    org.testng.internal.TestNGClassFinder.(TestRunner.java:409)
         at org.testng.TestRunner.init(TestRunner.java:235)
         at org.testng.TestRunner.init(TestRunner.java:205)
         at org.testng.TestRunner.(RemoteTestNG.java:141)
         at
    org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
         at
    org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
         at org.testng.SuiteRunner.init(SuiteRunner.java:157)
         at org.testng.SuiteRunner.(TestNG.java:1299)
         at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
         at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
         at org.testng.TestNG.run(TestNG.java:1057)
         at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
         at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
         at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at
    org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
         ... 21 more
    Caused by: org.openqa.selenium.UnsupportedCommandException: unknown
    command: hub/session
    Command duration or timeout: 980 milliseconds
    Build info: version: '2.38.0', revision: 'bd32d4e', time: '2013-12-05
    16:15:38'
    System info: host: 'waessve', ip: '10.194.11.166', os.name: 'Windows 7',
    os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at
    org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
         at
    org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
         at
    org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
         at
    org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
         at
    org.openqa.selenium.remote.RemoteWebDriver.(FirefoxDriver.java:197)
         at
    org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:186)
         at
    org.openqa.selenium.firefox.FirefoxDriver.(UserTest.java:26)
         ... 26 more

    On Friday, September 21, 2012 6:00:39 PM UTC+1, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*

    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*

    * if
    (Common.IsElementPresent(By.CssSelector("a[class='app12']")))*
    * {*
    *
    Common.waitforElement(By.CssSelector("a[class='app12']"));*
    *
    driver.FindElement(By.CssSelector("a[class='app12']")).Click();*
    * }*

    * else if
    (Common.IsElementPresent(By.CssSelector("div[class='bicon']")))*
    * {*
    *
    driver.FindElement(By.CssSelector("div[class='bicon']")).Click(); //opens
    a new browser window after clicking the button*
    * }*

    *
    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    *
    Common.waitforElement(By.CssSelector("button[class='success']"));*

    * }*


    Thanks,

    Sirus
    --
    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 selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/15de16d7-b3ee-4250-8b80-39befe449560%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shawn McCarthy at Feb 28, 2014 at 5:56 pm
    Put something like the following in an AfterMethod ? That way it will run
    even if the test fails:

    if(driver != null) {
         driver.quit();
    }


    On Friday, February 28, 2014 9:44:55 AM UTC-7, sat wrote:

    Hi all,

    What is the best way to close the browsers after each run *(Especially
    Firefox )*.

    I am getting below error (If I forget to close my FF Browser manually
    ,before run the each test )

    Any idea from your side?

    To avoid the issue ,I have to close the the browser manually ,before run
    the each test .

    Thanks,
    SAT

    ==============================

    ========================================================================================================

    org.testng.TestNGException:
    Cannot instantiate class UserManagement.UserTest
    at
    org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
    at
    org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
    at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
    at
    org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
    at org.testng.TestRunner.initMethods(TestRunner.java:409)
    at org.testng.TestRunner.init(TestRunner.java:235)
    at org.testng.TestRunner.init(TestRunner.java:205)
    at org.testng.TestRunner.<init>(TestRunner.java:160)
    at
    org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:141)
    at
    org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
    at
    org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
    at org.testng.SuiteRunner.init(SuiteRunner.java:157)
    at org.testng.SuiteRunner.<init>(SuiteRunner.java:111)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
    Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at
    org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
    ... 21 more
    Caused by: org.openqa.selenium.UnsupportedCommandException: unknown
    command: hub/session
    Command duration or timeout: 980 milliseconds
    Build info: version: '2.38.0', revision: 'bd32d4e', time: '2013-12-05
    16:15:38'
    System info: host: 'waessve', ip: '10.194.11.166', os.name: 'Windows 7',
    os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
    Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at
    org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at
    org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at
    org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at
    org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at
    org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at
    org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:197)
    at
    org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
    at
    org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at
    org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
    at UserManagement.UserTest.<init>(UserTest.java:26)
    ... 26 more

    On Friday, September 21, 2012 6:00:39 PM UTC+1, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*

    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*

    * if
    (Common.IsElementPresent(By.CssSelector("a[class='app12']")))*
    * {*
    *
    Common.waitforElement(By.CssSelector("a[class='app12']"));*
    *
    driver.FindElement(By.CssSelector("a[class='app12']")).Click();*
    * }*

    * else if
    (Common.IsElementPresent(By.CssSelector("div[class='bicon']")))*
    * {*
    *
    driver.FindElement(By.CssSelector("div[class='bicon']")).Click(); //opens
    a new browser window after clicking the button*
    * }*

    *
    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    *
    Common.waitforElement(By.CssSelector("button[class='success']"));*

    * }*


    Thanks,

    Sirus
    --
    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 selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5f3d4914-7f45-4e0c-a194-06b7f180b5e7%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Vikas Gahlaut at Mar 10, 2014 at 8:55 am
    driver.close() will close current window and driver.quit will close all
    window
    On Friday, September 21, 2012 10:30:39 PM UTC+5:30, sirus wrote:

    Hello Selenium Experts,

    I am having trouble closing the new browser pop up which appears after
    clicking the button. I am able to open a new window and switch to the main
    window but not able to close the main window.

    When i say driver.close() after swithcing to new window, it closes the
    main window and fails the test.

    Can anyone experience this problem?

    If yes, can you please help me find the solution.

    Any help would be appreciated.


    Below is the webdriver code that I have.


    * public void Test1()*
    * {*
    * Methods Common = new Methods(driver); //calls the common
    class*

    * string originalHandle= driver.CurrentWindowHandle; //gets
    the current window handle*
    * driver.FindElement(By.LinkText("Developer")).Click();*

    * if
    (Common.IsElementPresent(By.CssSelector("a[class='app12']")))*
    * {*
    *
    Common.waitforElement(By.CssSelector("a[class='app12']"));*
    *
    driver.FindElement(By.CssSelector("a[class='app12']")).Click();*
    * }*

    * else if
    (Common.IsElementPresent(By.CssSelector("div[class='bicon']")))*
    * {*
    *
    driver.FindElement(By.CssSelector("div[class='bicon']")).Click(); //opens
    a new browser window after clicking the button*
    * }*

    *
    driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));*
    * driver.Close(); //closes the main window instead of popup
    and fails.*
    * driver.SwitchTo().Window(originalHandle);*
    *
    Common.waitforElement(By.CssSelector("button[class='success']"));*

    * }*


    Thanks,

    Sirus
    --
    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 selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/31403686-9b5e-43ce-abf1-5d11b2211440%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedSep 21, '12 at 5:07p
activeMar 10, '14 at 8:55a
posts14
users8
websiteseleniumhq.org

People

Translate

site design / logo © 2022 Grokbase