예제 #1
0
        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);
        }
예제 #2
0
        public void TestOnboarding()
        {
            // Switch to VPN client session
            this.vpnClient.Session.SwitchTo();
            LandingScreen landingScreen = new LandingScreen(this.vpnClient.Session);

            landingScreen.ClickLearnMoreHyperlink();

            // Go to onboarding screen 1
            OnboardingScreen onboardingScreen1 = new OnboardingScreen(this.vpnClient.Session, "OnboardingView1");

            Assert.AreEqual("Skip", onboardingScreen1.GetSkipText());
            Assert.AreEqual("Next", onboardingScreen1.GetNextButtonText());
            Assert.AreEqual("No activity logs", onboardingScreen1.GetTitle());
            Assert.AreEqual("We're Mozilla. We don't log your activity and we're always on your side.", onboardingScreen1.GetSubTitle());
            onboardingScreen1.ClickNextButton();

            // Go to onboarding screen 2
            OnboardingScreen onboardingScreen2 = new OnboardingScreen(this.vpnClient.Session, "OnboardingView2");

            Assert.AreEqual("Skip", onboardingScreen2.GetSkipText());
            Assert.AreEqual("Next", onboardingScreen2.GetNextButtonText());
            Assert.AreEqual("Device level encryption", onboardingScreen2.GetTitle());
            Assert.AreEqual("No one will see your location or activity, even on unsecure Wi-Fi networks.", onboardingScreen2.GetSubTitle());
            onboardingScreen2.ClickNextButton();

            // Go to onboarding screen 3
            OnboardingScreen onboardingScreen3 = new OnboardingScreen(this.vpnClient.Session, "OnboardingView3");

            Assert.AreEqual("Skip", onboardingScreen3.GetSkipText());
            Assert.AreEqual("Next", onboardingScreen3.GetNextButtonText());
            Assert.AreEqual("Servers in 39 countries", onboardingScreen3.GetTitle());
            Assert.AreEqual("Stand up to tech bullies and protect your access to the web.", onboardingScreen3.GetSubTitle());
            onboardingScreen3.ClickNextButton();

            // Go to onboarding screen 4
            LastOnboardingScreen onboardingScreen4 = new LastOnboardingScreen(this.vpnClient.Session);

            Assert.AreEqual("Get started", onboardingScreen4.GetGetStartedButtonText());
            Assert.AreEqual("Connect up to 5 devices", onboardingScreen4.GetTitle());
            Assert.AreEqual("Stream, download and game. We won't restrict your bandwidth.", onboardingScreen4.GetSubTitle());
            onboardingScreen4.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);

            Assert.AreEqual("VPN is off", mainScreen.GetTitle());

            // Setting Screen
            UserCommonOperation.UserSignOut(this.vpnClient);
        }
예제 #3
0
        /// <summary>
        /// Dispose the VPN session and close the app.
        /// </summary>
        public void Dispose()
        {
            // Close the application and delete the session
            if (this.Session != null)
            {
                this.Session.SwitchTo();
                try
                {
                    WindowsElement landingView = this.Session.FindElementByClassName("LandingView");
                }
                catch (InvalidOperationException)
                {
                    UserCommonOperation.UserSignOut(this);
                }

                this.Session.Quit();
                this.Session = null;
            }
        }
예제 #4
0
        public void TestExistingUserSignIn()
        {
            // 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);

            Assert.AreEqual("VPN is off", mainScreen.GetTitle());

            // Setting Screen
            UserCommonOperation.UserSignOut(this.vpnClient);
        }
예제 #5
0
        public void TestDevice()
        {
            // 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.ClickDeviceListButton();

            // Device Screen
            DeviceScreen deviceScreen = new DeviceScreen(this.vpnClient.Session);

            Assert.AreEqual("My devices", deviceScreen.GetTitle());
            Regex rgx = new Regex(@"^[1-5] of 5$");

            Assert.IsTrue(rgx.IsMatch(deviceScreen.GetDeviceSummary()));
            rgx = new Regex(@"^Devices with Mozilla VPN installed using your account. Connect up to [0-9] devices.$");
            Assert.IsTrue(rgx.IsMatch(deviceScreen.GetDevicePanelTitle()));
            Assert.IsTrue(deviceScreen.GetCurrentDeviceName().Contains(Environment.MachineName));
            Assert.AreEqual("Current device", deviceScreen.GetCurrentDeviceStatus());
            Assert.IsFalse(deviceScreen.GetCurrentDeviceRemoveButton().Displayed);

            // Try to remove one device if there are some other devices.
            deviceScreen.RandomDeleteOneDevice(this.desktop.Session);

            // Back to main screen
            this.vpnClient.Session.SwitchTo();
            deviceScreen.ClickBackButton();

            // Sign out
            UserCommonOperation.UserSignOut(this.vpnClient);
        }
예제 #6
0
        public void TestSetting()
        {
            // 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.ClickSettingsButton();

            // Setting Screen
            SettingScreen settingScreen = new SettingScreen(this.vpnClient.Session);

            Assert.IsNotNull(settingScreen.GetProfileImage());
            Assert.AreEqual(Environment.GetEnvironmentVariable("EXISTED_USER_NAME"), settingScreen.GetUserName());
            Assert.AreEqual("Manage account", settingScreen.GetManageAccountButtonText());
            Assert.AreEqual("Launch VPN app on computer startup", settingScreen.GetLaunchVPNStartupText());
            Assert.AreEqual("Notifications", settingScreen.GetNotificationButtonText());
            Assert.AreEqual("Network settings", settingScreen.GetNetworkSettingButtonText());
            Assert.AreEqual("Language", settingScreen.GetLanguageButtonText());
            Assert.AreEqual("About", settingScreen.GetAboutButtonText());
            Assert.AreEqual("Get help", settingScreen.GetHelpButtonText());
            Assert.AreEqual("Give feedback", settingScreen.GetGiveFeedbackText());
            Assert.IsTrue(settingScreen.GetLaunchVPNStartupCheckBox().Enabled);

            // Click Manage Account button
            settingScreen.ClickManageAccountButton();
            this.browser.Session.SwitchTo();
            Assert.IsTrue(this.browser.GetCurrentUrl().Contains(Constants.ManageAccountUrl));

            // Test checkbox state remain after nav
            bool prevLaunchVPNStartupState = settingScreen.GetLaunchVPNStartupCheckBox().Selected;

            settingScreen.ClickLaunchVPNStartupCheckbox();
            bool expectedCurrentLaunchVPNStartupState = !prevLaunchVPNStartupState;

            // Nav back to main screen
            settingScreen.ClickBackButton();

            // nav back to setting screen again to check the state remaining the same
            mainScreen = new MainScreen(this.vpnClient.Session);
            mainScreen.ClickSettingsButton();

            // Verify the state
            settingScreen = new SettingScreen(this.vpnClient.Session);
            bool currentLaunchVPNStartupState = settingScreen.GetLaunchVPNStartupCheckBox().Selected;

            Assert.AreEqual(expectedCurrentLaunchVPNStartupState, currentLaunchVPNStartupState);

            // Click the notification button
            settingScreen.ScrollDown();
            settingScreen.ClickNotificationButton();
            NotificationsScreen notificationsScreen = new NotificationsScreen(this.vpnClient.Session);

            Assert.AreEqual("Notifications", notificationsScreen.GetTitle());
            Assert.AreEqual("Unsecured network alert", notificationsScreen.GetUnsecuredNetworkAlertText());
            Assert.AreEqual("Get notified if you connect to an unsecured Wi-Fi network", notificationsScreen.GetUnsecuredNetworkAlertDescription());
            Assert.AreEqual("Guest Wi-Fi portal alert", notificationsScreen.GetGuestWifiPortalAlertText());
            Assert.AreEqual("Get notified if a guest Wi-Fi portal is blocked due to VPN connection", notificationsScreen.GetGuestWifiPortalAlertDescription());

            // Check the state remain after nav
            bool prevUnsecuredNetworkAlertState = notificationsScreen.IsUnsecuredNetworkAlertChecked();
            bool prevGuestWifiPortalAlertState  = notificationsScreen.IsGuestWifiPortalAlertChecked();

            notificationsScreen.ClickUnsecuredNetworkAlertCheckBox();
            notificationsScreen.ClickGuestWifiPortalAlertCheckBox();
            bool expectedCurrentUnsecuredNetworkAlertState = !prevUnsecuredNetworkAlertState;
            bool expectedCurrentGuestWifiPortalAlertState  = !prevGuestWifiPortalAlertState;

            // Nav back to setting screen
            notificationsScreen.ClickBackButton();
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickNotificationButton();

            // Verifiy alert state
            notificationsScreen = new NotificationsScreen(this.vpnClient.Session);
            Assert.AreEqual(expectedCurrentUnsecuredNetworkAlertState, notificationsScreen.IsUnsecuredNetworkAlertChecked());
            Assert.AreEqual(expectedCurrentGuestWifiPortalAlertState, notificationsScreen.IsGuestWifiPortalAlertChecked());
            notificationsScreen.ClickBackButton();

            // Nav to Network Settings screen
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickNetworkSettingButton();

            // On network settings screen
            NetworkSettingsScreen networkSettingsScreen = new NetworkSettingsScreen(this.vpnClient.Session);
            bool preEnableIPv6  = networkSettingsScreen.IsEnableIPv6Checked();
            bool preAllowAccess = networkSettingsScreen.IsAllowAccessChecked();

            Assert.AreEqual("Network settings", networkSettingsScreen.GetTitle());
            Assert.AreEqual("Enable IPv6", networkSettingsScreen.GetEnableIPv6CheckBoxText());
            Assert.AreEqual("Push the internet forward with the latest version of the Internet Protocol", networkSettingsScreen.GetEnableIPv6Description());
            Assert.IsFalse(networkSettingsScreen.IsEnableIPv6DisabledMessageDisplayed());
            Assert.AreEqual("Local network access", networkSettingsScreen.GetAllowAccessText());
            Assert.AreEqual("Access printers, streaming sticks and all other devices on your local network", networkSettingsScreen.GetAllowAccessDescription());
            Assert.IsFalse(networkSettingsScreen.IsAllowAccessDisabledMessageDisplayed());

            // check the checkbox state after click
            networkSettingsScreen.ClickAllowAccessCheckBox();
            networkSettingsScreen.ClickEnableIPv6CheckBox();
            bool expectedEnableIPv6  = !preEnableIPv6;
            bool expectedAllowAccess = !preAllowAccess;

            networkSettingsScreen.ClickBackButton();

            // Back to main screen to turn on vpn
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickBackButton();
            mainScreen = new MainScreen(this.vpnClient.Session);
            mainScreen.ToggleVPNSwitch();
            mainScreen.ClickSettingsButton();

            // Check Network setting screen again
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ScrollDown();
            settingScreen.ClickNetworkSettingButton();
            networkSettingsScreen = new NetworkSettingsScreen(this.vpnClient.Session);
            bool currentAllowAccessState = networkSettingsScreen.IsAllowAccessChecked();
            bool currentEnableIPv6       = networkSettingsScreen.IsEnableIPv6Checked();

            Assert.AreEqual(expectedAllowAccess, currentAllowAccessState);
            Assert.AreEqual(expectedEnableIPv6, currentEnableIPv6);
            Assert.IsFalse(networkSettingsScreen.IsAllowAccessEnabled());
            Assert.IsTrue(networkSettingsScreen.IsAllowAccessDisabledMessageDisplayed());
            Assert.AreEqual($"VPN must be off before {(currentAllowAccessState ? "disabling" : "enabling")}", networkSettingsScreen.GetAllowAccessDisabledMessage());
            Assert.IsFalse(networkSettingsScreen.IsEnableIPv6Enabled());
            Assert.IsTrue(networkSettingsScreen.IsEnableIPv6DisabledMessageDisplayed());
            Assert.AreEqual($"VPN must be off before {(currentEnableIPv6 ? "disabling" : "enabling")}", networkSettingsScreen.GetEnableIPv6DisabledMessage());
            networkSettingsScreen.ClickBackButton();

            // Back to main screen to turn off vpn
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickBackButton();
            mainScreen = new MainScreen(this.vpnClient.Session);
            mainScreen.ToggleVPNSwitch();
            mainScreen.ClickSettingsButton();

            // Nav to language screen
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ScrollDown();
            settingScreen.ClickLanguageButton();

            // On language screen
            LanguageScreen languageScreen = new LanguageScreen(this.vpnClient.Session);

            languageScreen.RandomPickAdditionalLanguage();

            // Reset back to English
            languageScreen.ClickDefaultLanguageRadioButton();
            languageScreen.ClickBackButton();

            // Nav to About screen
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickAboutButton();

            // About screen
            AboutScreen aboutScreen = new AboutScreen(this.vpnClient.Session);

            Assert.AreEqual("Firefox Private Network", aboutScreen.GetFPNTitle());
            Assert.AreEqual("A fast, secure and easy to use VPN \r\n(Virtual Private Network).", aboutScreen.GetFPNSubtitle());
            Assert.AreEqual("Release version", aboutScreen.GetReleaseTitle());
            Console.WriteLine($"Version: {aboutScreen.GetReleaseVersion()}");
            Assert.IsTrue(Regex.IsMatch(aboutScreen.GetReleaseVersion(), @"^\d+.\d+[abAB]?$"));

            // Click terms of service button
            this.vpnClient.Session.SwitchTo();
            aboutScreen.ClickTermsOfService();
            this.browser.Session.SwitchTo();
            string actualTermsOfServiceUrl = this.browser.GetCurrentUrl();

            Console.WriteLine($"Terms of service url: {actualTermsOfServiceUrl}");
            Assert.IsTrue(actualTermsOfServiceUrl.Contains(Constants.TermsOfServiceUrl));

            // Click privacy policy button
            this.vpnClient.Session.SwitchTo();
            aboutScreen.ClickPrivacyPolicy();
            this.browser.Session.SwitchTo();
            string actualPrivacyPolicyUrl = this.browser.GetCurrentUrl();

            Console.WriteLine($"Privacy Policy url: {actualPrivacyPolicyUrl}");
            Assert.IsTrue(actualPrivacyPolicyUrl.Contains(Constants.PrivacyPolicyUrl));

            // Click the Debug button
            this.vpnClient.Session.SwitchTo();
            aboutScreen.ClickDebug();

            // On Privacy Notice popup
            PrivacyNoticePopup privacyNoticePopup = new PrivacyNoticePopup(this.vpnClient.Session);

            Assert.AreEqual(Utils.CleanText(Constants.PrivacyNotice), Utils.CleanText(privacyNoticePopup.GetPrivacyNoticeDetails()));
            privacyNoticePopup.ClickYesButton();

            // Open Export Debug package window
            ExportWindow exportDebugPackageWindow = new ExportWindow(this.vpnClient.Session, "Export debug package");

            exportDebugPackageWindow.SaveFile(this.folderPath, this.debugFileName);
            Assert.IsTrue(Utils.WaitUntilFileExist(Path.Combine(this.folderPath, this.debugFileName)));

            // Click viewlog button
            aboutScreen.ClickViewLog();
            LogWindow logWindow = new LogWindow(this.desktop.Session);

            Assert.AreEqual("Timestamp", logWindow.GetTimeStampColumnHeader());
            Assert.AreEqual("Message", logWindow.GetMessageColumnHeader());
            Assert.IsTrue(logWindow.GetNumberOfLogs() > 0);

            // Click save button on view log window
            logWindow.ClickSaveButton();

            // Open SaveLog window
            ExportWindow saveLogWindow = new ExportWindow(this.desktop.Session, "Save log");

            saveLogWindow.SaveFile(this.folderPath, this.logFileName);
            Assert.IsTrue(Utils.WaitUntilFileExist(Path.Combine(this.folderPath, this.logFileName)));

            // Back to setting screen
            logWindow.CloseWindow();
            aboutScreen.ClickBackButton();

            // Click Get Help button
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickGetHelpButton();

            // On Get Help Screen
            GetHelpScreen getHelpScreen = new GetHelpScreen(this.vpnClient.Session);

            Assert.AreEqual("Get help", getHelpScreen.GetTitle());
            Assert.AreEqual("Contact us", getHelpScreen.GetContactUs());
            Assert.AreEqual("Help & Support", getHelpScreen.GetHelpAndSupport());

            // Click contact us button
            this.vpnClient.Session.SwitchTo();
            getHelpScreen.ClickContactUs();
            this.browser.Session.SwitchTo();
            string actualContactUsUrl = this.browser.GetCurrentUrl();

            Console.WriteLine($"Contact us url: {actualContactUsUrl}");
            Assert.IsTrue(actualContactUsUrl.Contains(Constants.ContactUsUrl));

            // Click help and support button
            this.vpnClient.Session.SwitchTo();
            getHelpScreen.ClickHelpAndSupport();
            this.browser.Session.SwitchTo();
            string actualHelpSupportUrl = this.browser.GetCurrentUrl();

            Console.WriteLine($"Help and support url: {actualHelpSupportUrl}");
            Assert.IsTrue(actualHelpSupportUrl.Contains(Constants.SupportUrl));

            // Back to setting screen
            this.vpnClient.Session.SwitchTo();
            getHelpScreen.ClickBackButton();

            // Click Give feedback button
            settingScreen = new SettingScreen(this.vpnClient.Session);
            settingScreen.ClickGiveFeedbackLink();
            this.browser.Session.SwitchTo();
            Assert.IsTrue(this.browser.GetCurrentUrl().Contains(Constants.FeedbackUrl));

            // Sign out
            this.vpnClient.Session.SwitchTo();
            settingScreen.ClickSignOutButton();
        }