Example #1
0
        public void ThenINavigateToSalesForceUrl()
        {
            string salesurl = _autoutilities.GetKeyValue("SalesURL", "SalesforceUrl");

            Console.WriteLine("SalesForce URL: " + salesurl);
            driver.Navigate().GoToUrl(salesurl);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            driver.Manage().Window.Maximize();
            _salesforcelogin = new SalesforceLoginPage(driver);
            //_salesforcehomepage = new SalesforceHomePage(driver);
        }
Example #2
0
        /// <summary>
        /// Method for getting the Run Id for Test Rail from the Config file
        /// </summary>
        /// <returns></returns>
        public string GetRunIdForTestRail()
        {
            string RunId = "";

            try
            {
                RunId = _autoutilities.GetKeyValue("TestRailConfig", "ExistingRunID");
                _testRailUtilsLog.Info("RunID is : " + _testRailUtilsLog);
            }
            catch (Exception ex)
            {
                _testRailUtilsLog.Error("Unable to get the RunId from the Config File: " + ex.ToString());
            }
            return(RunId);
        }
Example #3
0
        /// <summary>
        ///Getter method for Webdriver in which instance the testcase need to run whether on linear mode/null or remote mode(Grid and Saucelabs) Use this whenever want to use/pass webdriver
        /// </summary>
        /// <params>None</params>
        /// <return>Webdriver Instance</returns>

        public IWebDriver GetDriver()
        {
            if (_autoutilities.GetKeyValue("MODEOFEXECUTION", "ExecutionMode").ToLower() == "linear" || _autoutilities.GetKeyValue("MODEOFEXECUTION", "ExecutionMode") == "" || _autoutilities.GetKeyValue("MODEOFEXECUTION", "ExecutionMode").ToLower() == null)
            {
                Driver = InitialSetupWebdriver();
            }
            else if (_autoutilities.GetKeyValue("MODEOFEXECUTION", "ExecutionMode").ToLower() == "remote")
            {
                //Driver = new RemoteBrowser().InitialiseRemoteDriver();
            }

            WebListener webListener = new WebListener(Driver);

            Driver = webListener.Driver;

            return(Driver);
        }
Example #4
0
        /// <summary>
        /// Parameterized Constructor with the SheetName
        /// </summary>
        /// <params>Sheetname as String</params>
        /// <return>none</returns>

        public ExcelManager(string sheetName)
        {
            _autoutilities   = new AutomationUtilities();
            excelPath        = _autoutilities.GetKeyValue("INPUTDATAPATH", "ExcelDataPath");
            ExcelApp         = new Application();
            ExcelApp.Visible = true;
            MyBook           = ExcelApp.Workbooks.Open(excelPath);
            MySheet          = (Worksheet)MyBook.Worksheets.get_Item(sheetName); // Explicit cast is not required here
        }
        /// <summary>
        /// Method for initializing RemoteDriver and Invoke Remote driver based on browser type specified in config file ie  If the browser type is null it will take as ff and other than chrome,ff/firefox or null ,  it will provide an error message of invalid browser type
        /// </summary>
        /// <params>None</params>
        /// <return>WebDriver Reference</returns>

        public IWebDriver InitialiseRemoteDriver(string sBrowserType)
        {
            _autoutilities = new AutomationUtilities();
            //  string sBrowserType = _autoutilities.GetKeyValue("BROWSER", "Browser").ToLower();
            string _ip = _autoutilities.GetKeyValue("REMOTE", "IP");

            switch (sBrowserType)
            {
            case "ie":
            case "iexplore":
                SetRemoteDriver("internet explorer", _ip);
                break;

            case "ff":
            case "firefox":
                SetRemoteDriver("firefox", _ip);
                break;

            case "chrome":
                SetRemoteDriver("chrome", _ip);
                break;

            case "safari":
                SetRemoteDriver("safari", _ip);
                break;

            case "":
                SetRemoteDriver("firefox", _ip);
                break;

            default:
                Assert.Fail(" Browser name mentioned in config file is Invalid");
                break;
            }
            return(GetRemoteDriver());
        }
        /// <summary>
        ///Method for setting the Remote Driver for GRID as well as Sauce Labs
        /// </summary>
        /// <params>browsertype as String and IP as String</params>
        /// <return>none</returns>
        public void SetRemoteDriver(string sBrowserType, string ip)
        {
            _autoutilities = new AutomationUtilities();
            string executionMode = _autoutilities.GetKeyValue("MODEOFEXECUTION", "ExecutionMode").ToLower();

            try
            {
                /// compare the execution mode and IP that are specified in config file is Grid then execute the test in Grid else execute in saucelabs
                if (executionMode.Equals("remote") && _autoutilities.GetKeyValue("REMOTE", "IP").Contains("4444"))
                {
                    DesiredCapabilities capabilities = new DesiredCapabilities();
                    capabilities.SetCapability(CapabilityType.BrowserName, sBrowserType);
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
                    this.Driver = new RemoteWebDriver(new Uri("http://" + ip + "/wd/hub"), capabilities, TimeSpan.FromSeconds(300));
                    this.Driver.Manage().Cookies.DeleteAllCookies();
                }
                //Running on Browser Stack ....
                else if (executionMode.Equals("remote") && _autoutilities.GetKeyValue("REMOTE", "IP").Contains("browserstack"))
                {
                    DesiredCapabilities capability = new DesiredCapabilities();
                    capability.SetCapability("os", "OS X");
                    capability.SetCapability("os_version", "Mojave");
                    capability.SetCapability("browser", "Safari");
                    capability.SetCapability("browser_version", "12.0");
                    capability.SetCapability("resolution", "1920x1080");
                    capability.SetCapability("project", "Mac_Safari12");
                    capability.SetCapability("build", "Build_Test");
                    capability.SetCapability("browserstack.user", "silpavajja2");
                    capability.SetCapability("browserstack.key", "3BqtD3z8zqJn4ZEqyZy7");

                    this.Driver = new RemoteWebDriver(new Uri("http://" + ip + "/wd/hub"), capability, TimeSpan.FromSeconds(300));
                }
                // execute the test using saucelabs
                else if (executionMode.Equals("remote") && _autoutilities.GetKeyValue("REMOTE", "IP").Contains("saucelabs"))
                {
                    string SAUCE_LABS_ACCOUNT_NAME = _autoutilities.GetKeyValue("REMOTE", "SAUCE_LABS_ACCOUNT_NAME");
                    string SAUCE_LABS_ACCOUNT_KEY  = _autoutilities.GetKeyValue("REMOTE", "SAUCE_LABS_ACCOUNT_KEY");
                    // string browserName = _autoutilities.GetKeyValue("BROWSER", "Browser").ToLower();
                    string version  = "34";
                    string platform = "Windows 7";
                    DesiredCapabilities desiredCapabilites = new DesiredCapabilities(sBrowserType, version, Platform.CurrentPlatform); // set the desired browser
                    desiredCapabilites.SetCapability("platform", platform);                                                            // operating system to use
                    desiredCapabilites.SetCapability("username", SAUCE_LABS_ACCOUNT_NAME);                                             // supply sauce labs username
                    desiredCapabilites.SetCapability("accessKey", SAUCE_LABS_ACCOUNT_KEY);                                             // supply sauce labs account key
                    //      desiredCapabilites.SetCapability("name", TestContext.CurrentContext.Test.Name); // give the test a name
                    this.Driver = new RemoteWebDriver(new Uri("http://" + ip + "/wd/hub"), desiredCapabilites, TimeSpan.FromSeconds(300));
                    this.Driver.Manage().Cookies.DeleteAllCookies();
                }

                MaximizeBrowser();
            }
            catch (WebException e)
            {
                log.Error("Error while Initializing the Remote Webdriver " + e.Message);
                Assert.Fail("Error while Initializing the Remote Webdriver " + e.Message.Replace('{', '[').Replace('}', ']'));
            }
            catch (Exception e)
            {
                log.Error("Error while Initializing the Remote Webdriver " + e.Message);
                Assert.Fail("Error while Initializing the Remote Webdriver " + e.Message.Replace('{', '[').Replace('}', ']'));
            }
        }