Exemplo n.º 1
0
        public void DebugLocalChrome()
        {
            try
            {
                //set configuration to be picked up and set Locator
                Config  = false;
                Browser = "Chrome";
                Env     = "Desktop";

                string path = TestUtility.GetAssemblyDirectory() + "\\chromedriver.exe";
                Environment.SetEnvironmentVariable("webdriver.chrome.driver", path);

                ChromeOptions chrOpts = new ChromeOptions();
                chrOpts.AddArguments("test-type");
                //chrOpts.AddArguments("--disable-extensions");
                chrOpts.AddArguments("no-sandbox");
                //chrOpts.AddArgument("incognito");
                chrOpts.AddUserProfilePreference("download.prompt_for_download", ConfigurationManager.AppSettings["ShowBrowserDownloadPrompt"]);
                driver = new ChromeDriver(chrOpts);
                driver.Manage().Window.Maximize();
                //driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings.Get("ElementPageLoad"))));
                ExtentReport.StartTest(TestContext.CurrentContext.Test.Name);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        public bool click(By locator, string locatorName)
        {
            bool flag = true;

            try
            {
                /*Highlight element*/
                WebElement         webElement = driver.FindElement(locator);
                JavascriptExecutor js         = driver as JavascriptExecutor;
                js.ExecuteScript("arguments[0].style.border='2px solid yellow'", webElement);
                js.ExecuteScript("arguments[0].click();", webElement);
                /*Highlight code ends*/
                //Thread.Sleep(500);
                // driver.FindElement(locator).Click();
                //js.ExecuteScript("arguments[0].click();", webElement);
                //flag = true;
                ExtentReport.ReportPass("The Element <b>" + locatorName + "</b> Click Successfull");
            }
            catch (Exception ex)
            {
                //TakeScreenShot();
                ExtentReport.ReportPass("The Element <b>" + locatorName + "</b> Click Failed :" + ex.Message);
                return(flag);
            }
            return(flag);
        }
Exemplo n.º 3
0
        public bool waitForVisibilityOfElement(By lookupBy, double timeout)
        {
            bool          flag = false;
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));

            try
            {
                WebElement ele = wait.Until(ExpectedConditions.ElementIsVisible(lookupBy));
                flag = true;
                ExtentReport.ReportPass("The element is visible before <b>" + timeout + "</b> seconds");
            }
            catch (Exception ex)
            {
                try
                {
                    //TakeScreenShot();
                    ExtentReport.ReportFail("The element is not visible :<b>" + ex.Message + "</b>");
                    //Assert.Fail(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
                    flag = false;
                }
                catch (Exception ex1)
                {
                    //Assert.Fail("Failed to take screenshot: " + ex1.ToString());
                }
            }

            return(flag);
        }
Exemplo n.º 4
0
 public void EnterText(By Locator, string Value, string LocatorName)
 {
     try
     {
         Thread.Sleep(1000);
         setValueToObject(Locator, Value, 60);
         ExtentReport.ReportPass("The Value <b>" + Value + "</b> Entered in Locator <b>" + LocatorName + "</b> Successfully");
     }
     catch (Exception e)
     {
         //TakeScreenShot();
         ExtentReport.ReportFail("The Value <b>" + Value + "</b> Entered in Locator <b>" + LocatorName + "</b> Failed : " + e.Message);
         throw new Exception("Error Occured in Entering Text " + e.Message);
     }
 }
Exemplo n.º 5
0
        public string getValue(By lookupBy, string locatorName)
        {
            string value = "";

            try
            {
                if (isElementPresent(lookupBy, locatorName))
                {
                    value = driver.FindElement(lookupBy).GetAttribute("value");
                }

                ExtentReport.ReportPass(" The value <b>" + value + "</b> fetching is success from Locator <b>" + locatorName + "</b>");
            }
            catch (Exception ex)
            {
                //TakeScreenShot();
                ExtentReport.ReportFail(" The value <b>" + value + "</b> fetching is failed from Locator <b>" + locatorName + "</b> : " + ex.Message);
                throw new Exception("Unable to get Text from " + locatorName + "<br />" + ex.Message);
            }
            return(value);
        }
Exemplo n.º 6
0
        public IWebDriver TestSetup(string strMobileDevice)
        {
            browserstack_user = ConfigurationManager.AppSettings.Get("browserstackuser");
            browserstack_key  = ConfigurationManager.AppSettings.Get("browserstackkey");

            //Code in TestFixture
            DebugBSChrome();
            DebugBSMobile(strMobileDevice);
            DebugLocalMobile(strMobileDevice);
            DebugLocalChrome();

            //driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(180));
            VerifyPageIsLoaded();
            driver.Navigate().GoToUrl(WebuiURL);
            ExtentReport.ReportPass("Successfully navigated to URL " + WebuiURL);
            // Update Env build and browser in DB
            ResultDbHelper _result = new ResultDbHelper();

            //_result.UpdateEnvdetails(Env, Browser, "");

            return(driver);
        }