/// <summary> /// User click the toggle switch to connect to VPN. /// </summary> /// <param name="vpnClient">VPN session.</param> /// <param name="desktop">Desktop session.</param> public static void ConnectVPN(FirefoxPrivateVPNSession vpnClient, DesktopSession desktop) { // Click VPN switch toggle and turn on VPN vpnClient.Session.SwitchTo(); MainScreen mainScreen = new MainScreen(vpnClient.Session); Assert.AreEqual("VPN is off", mainScreen.GetTitle()); Assert.AreEqual("Turn it on to protect your entire device", mainScreen.GetSubtitle()); Assert.IsTrue(mainScreen.GetOffImage().Displayed); Assert.IsFalse(mainScreen.GetOnImage().Displayed); mainScreen.ToggleVPNSwitch(); // Verify the windows notification desktop.Session.SwitchTo(); WindowsNotificationScreen windowsNotificationScreen = new WindowsNotificationScreen(desktop.Session); Assert.AreEqual("VPN is on", windowsNotificationScreen.GetTitleText()); Assert.AreEqual("You're secure and protected.", windowsNotificationScreen.GetMessageText()); windowsNotificationScreen.ClickDismissButton(); // Verify user is connected to Mullvad VPN IRestResponse response = Utils.AmIMullvad("You are connected to Mullvad"); Console.WriteLine($"After connection - Mullvad connected API response: {response.Content}"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsTrue(response.Content.Contains("You are connected to Mullvad")); // Verify the changes on main screen vpnClient.Session.SwitchTo(); Assert.IsTrue(mainScreen.GetOnImage().Displayed); Assert.IsFalse(mainScreen.GetOffImage().Displayed); Assert.AreEqual("VPN is on", mainScreen.GetTitle()); Assert.IsTrue(mainScreen.GetSubtitle().Contains("Secure and protected")); }
public void TestVPNConnection() { // Switch to VPN client session this.vpnClient.Session.SwitchTo(); LandingScreen landingScreen = new LandingScreen(this.vpnClient.Session); landingScreen.ClickGetStartedButton(); // User Sign In via web browser UserCommonOperation.UserSignIn(this.vpnClient, this.browser); // Main Screen this.vpnClient.Session.SwitchTo(); MainScreen mainScreen = new MainScreen(this.vpnClient.Session); mainScreen.ClickServerListButton(); // Server Screen ServerListScreen serverListScreen = new ServerListScreen(this.vpnClient.Session); serverListScreen.RandomSelectDifferentCityServer("Miami"); string prevCity = serverListScreen.GetSelectedCity(); Console.WriteLine("Before switching: the selected city is {0}", prevCity); // User turns on VPN UserCommonOperation.ConnectVPN(this.vpnClient, this.desktop); // Click the server button mainScreen = new MainScreen(this.vpnClient.Session); mainScreen.ClickServerListButton(); // Select a random US server serverListScreen = new ServerListScreen(this.vpnClient.Session); serverListScreen.RandomSelectDifferentCityServer("Atlanta"); string currentCity = serverListScreen.GetSelectedCity(); Console.WriteLine("After switching: the selected city is {0}", currentCity); // Check the subtitle Assert.AreEqual(string.Format("From {0} to {1}", prevCity, currentCity), mainScreen.GetSubtitle()); // Check the windows notification again this.desktop.Session.SwitchTo(); WindowsNotificationScreen windowsNotificationScreen = new WindowsNotificationScreen(this.desktop.Session); Assert.AreEqual(string.Format("From {0} to {1}", prevCity, currentCity), windowsNotificationScreen.GetTitleText()); Assert.AreEqual("You switched servers.", windowsNotificationScreen.GetMessageText()); windowsNotificationScreen.ClickDismissButton(); // User turns off VPN UserCommonOperation.DisconnectVPN(this.vpnClient, this.desktop); // Sign out UserCommonOperation.UserSignOut(this.vpnClient); }