Working with popup windows using Coypu for Selenium C#
Karthik kk
In the last post we discussed how to write a super simple code with Coypu for Selenium with C#, in this post we will discuss how to work with popup windows using Coypu for Selenium with C#.
Here are some of the difference between Selenium from coypu
Here is the complete video of the above discussion
Here is the complete code from the above video
[TestMethod]
public void Test_PopupWindow()
{
var sessionConfiguration = new SessionConfiguration()
{
Browser = Browser.Firefox,
AppHost = "executeautomation.com",
};
var browser = new BrowserSession(sessionConfiguration);
browser.Visit("/demosite/Login.html");
browser.FillIn("UserName").With("admin");
browser.FillIn("Password").With("password");
browser.ClickButton("Login");
browser.ClickLink("HtmlPopup");
//Switch to window
var popup = browser.FindWindow("Popup Window", Options.Substring);
//Select title
popup.Select("Ms.").From("TitleId");
//Type Initial
popup.FillIn("Initial").With("KK");
//First Name
popup.FillIn("FirstName").With("Karthik");
//Middle Name
popup.FillIn("MiddleName").With("Mi");
//Gender
popup.Choose("female");
//Close the window
popup.ExecuteScript("self.close();");
browser.FindWindow("Execute Automation");
//Select title
browser.Select("Ms.").From("TitleId");
}
Thanks for reading the post and watching the video!!!
Please leave your comments and let me know if there is anything I should update in this post.
Thanks,
Karthik KK