Test Environment - Working on writing tests in Selenium web driver in C#.net. And running them via NUnit. The base url - http://localhost/OnlineTest/login.aspx Inside of this there is an iframe, insid开发者_运维知识库e of which there is a grid, Here is what I want to automate.
• Go to the Grid
• Click on an image.
• It opens new window(like a pop up).
• Go to that window .
• Verify its text & click Close button.
I am not able to find a way to go to another window via code.
This is what I have tried - IWebElement element= driver.SwitchTo().Window("ViewQuestionPreview.aspx?QsnId=Qsn16").FindElement(By.Id("btnClose"));
I have also changed the URL to different combinitions like
- "/ViewQuestionPreview.aspx?QsnId=Qsn16"
- "http://localhost/OnlineTest/ViewQuestionPreview.aspx?QsnId=Qsn16"
- "/OnlineTest/ViewQuestionPreview.aspx?QsnId=Qsn16"
"OnlineTest/ViewQuestionPreview.aspx?QsnId=Qsn16"
Error - No such Window found. NoSuchWindowException
would appreciate of someone can help.
Tahir
Try using driver.switchTo().frame(). Frame have two functions. One which takes int values and another which take string. Hope this helps.
The command you are using i.e switchTo().window(windowName) here windowName is name of window where control is going to shift and you get this name from javascript or link which opens it. This doesn't need path of window which you are trying to pass. Try to look at window's name.
Thanks, Hope this will help you.
精彩评论