0

the code is self.close(); some times the window is closed and sometime it doesn't closed and not throwing any popup or alert. So i wanted to check whether the window is closed or still open? How it can be done through selenium?

1 Answer 1

0

Assuming I understand your question correctly... You should store the ID (of the window you're trying to close) in a variable.

After calling the close method, check if the window ID still exists. If it does, something went wrong.

Example in C#. Instead of the String.Equals check, you can also get a list of all windowHandles and check if the specific handle is still in it. Edit: didn't test this, just an idea to get you going.

string handle = driver.CurrentWindowHandle;
driver.Close();
if (String.Equals(handle, driver.CurrentWindowHandle))
    throw new Exception("Not closed!");
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.