예제 #1
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
        public void clickButton(string sButtonName, string sType, string sObjectLocator)
        {
            try
            {
                waitForElementIsPresent(sButtonName, Constants.TIME_OUT, sObjectLocator);
                switch (sType)
                {
                case "id":
                    getDriver.FindElement(By.Id(sObjectLocator)).Click();
                    break;

                case "xpath":
                    getDriver.FindElement(By.XPath(sObjectLocator)).Click();
                    break;

                case "name":
                    getDriver.FindElement(By.Name(sObjectLocator)).Click();
                    break;

                case "classname":
                    getDriver.FindElement(By.ClassName(sObjectLocator)).Click();
                    break;

                case "tagname":
                    getDriver.FindElement(By.TagName(sObjectLocator)).Click();
                    break;
                }
                ExReports.reportPass("Button '" + sButtonName + "' is clicked");
            }
            catch (Exception e)
            {
                ExReports.reportFail("Button '" + sButtonName + "' is not clicked. " + e.Message);
                throw;
            }
        }
예제 #2
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
        public bool waitForElementIsPresent(string sName, string sType, string sObjectLocator, int iTimeOut)
        {
            try
            {
                WebDriverWait wait = new WebDriverWait(getDriver, TimeSpan.FromSeconds(iTimeOut));
                switch (sType)
                {
                case "id":
                    wait.Until(ExpectedConditions.ElementIsVisible((By.Id(sObjectLocator))));
                    ExReports.reportInfo("Element '" + sName + "' is found");
                    return(true);

                case "name":
                    wait.Until(ExpectedConditions.ElementIsVisible((By.Name(sObjectLocator))));
                    ExReports.reportPass("Element '" + sName + "' is found");
                    return(true);

                case "xpath":
                    wait.Until(ExpectedConditions.ElementIsVisible((By.XPath(sObjectLocator))));
                    ExReports.reportPass("Element '" + sName + "' is found");
                    return(true);

                case "link":
                    wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText(sObjectLocator)));
                    ExReports.reportPass("Element '" + sName + "' is found");
                    return(true);
                }
                return(false);
            }
            catch (WebDriverTimeoutException)
            {
                ExReports.reportFail("Timeout is over - Element '" + sName + "' is not found");
                throw;
            }
        }
예제 #3
0
파일: LogInTest.cs 프로젝트: gshustin/GLSH2
 public void Test04()
 {
     ExReports.createTest("Login with valid credentials");
     lp.clearUserNameAndPass();
     lp.inputCredentialsAndSubmit(USER_NAME, PASS);
     Profile.goToStore();
     Common.checkElementIsDisplayed("Logo", "logo");
     ExReports.reportPass("Login is successful");
 }
예제 #4
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
 public void clickLink(string sLink)
 {
     try
     {
         getDriver.FindElement(By.LinkText(sLink)).Click();
         ExReports.reportPass("Link is selected");
     }
     catch (Exception e)
     {
         ExReports.reportFail("Link is not clicked. " + e.Message);
         throw;
     }
 }
예제 #5
0
 public void pressBack()
 {
     try
     {
         driver.Navigate().Back();
         ExReports.reportPass("'Back' button is clicked");
     }
     catch (Exception e)
     {
         ExReports.reportFail(e.Message);
         throw;
     }
 }
예제 #6
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
 public void checkFieldIsEmpty(string sName, string sObjectLocator)
 {
     try
     {
         waitForElementIsPresent(sName, Constants.TIME_OUT, sObjectLocator);
         Assert.IsTrue(String.IsNullOrEmpty(getDriver.FindElement(By.Id(sObjectLocator)).GetAttribute("value")));
         ExReports.reportPass("Field '" + sName + "' is empty");
     } catch (AssertFailedException)
     {
         ExReports.reportFail("Field '" + sName + "' is not empty");
         throw;
     }
 }
예제 #7
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
 public void checkTextIsPresent(string sText)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(getDriver, TimeSpan.FromSeconds(Constants.TIME_OUT));
         wait.Until(ExpectedConditions.ElementIsVisible((By.XPath(String.Format("//*[contains(text(), '" + sText + "')]")))));
         ExReports.reportPass("Text '" + sText + "' is found on page");
     }
     catch (WebDriverTimeoutException)
     {
         ExReports.reportFail("Text '" + sText + "' is not found on page");
         throw;
     }
 }
예제 #8
0
파일: StorePage.cs 프로젝트: gshustin/GLSH2
 public void openItem()
 {
     try
     {
         Common.waitForElementIsPresent("Item link", "xpath", "//*[text()='iPhone 5']", Constants.TIME_OUT);
         lnkItem.Click();
         ExReports.reportPass("'Item link' is selected");
     }
     catch (Exception e)
     {
         ExReports.reportFail("Open item" + e.Message);
         throw;
     }
 }
예제 #9
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
 public void checkElementIsDisplayed(string sName, string sObjectLocator)
 {
     try
     {
         waitForElementIsPresent(sName, Constants.TIME_OUT, sObjectLocator);
         Assert.IsTrue(getDriver.FindElement(By.Id(sObjectLocator)).Displayed);
         ExReports.reportPass("Element '" + sName + "' is displayed");
     }
     catch (AssertFailedException e)
     {
         ExReports.reportFail("Element '" + sName + "' is not displayed. " + e.Message);
         throw;
     }
 }
예제 #10
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
 public void checkFieldValue(string sObjectLocator, string sValue)
 {
     try
     {
         waitForElementIsPresent(sValue, Constants.TIME_OUT, sObjectLocator);
         Assert.AreEqual(getDriver.FindElement(By.Id(sObjectLocator)).GetAttribute("value"), sValue);
         ExReports.reportPass("Check field - Value '" + sValue + "' is correct");
     }
     catch (AssertFailedException)
     {
         ExReports.reportFail("Check field - Value '" + sValue + "' is not correct");
         throw;
     }
 }
예제 #11
0
파일: StorePage.cs 프로젝트: gshustin/GLSH2
 public void addToCard()
 {
     try
     {
         Common.waitForElementIsPresent("Add to Card button", "classname", "wpsc_buy_button", Constants.TIME_OUT);
         BtnAddToCard.Click();
         ExReports.reportPass("Button 'Add to card' is clicked");
     }
     catch (Exception e)
     {
         ExReports.reportFail("Add to card" + e.Message);
         throw;
     }
 }
예제 #12
0
 public void selectCommands()
 {
     try
     {
         SelectElement oSelect = new SelectElement(Commands);
         oSelect.SelectByText("Navigation Commands");
         oSelect.SelectByText("Wait Commands");
         ExReports.reportPass("Two commands are selected");
     }
     catch (Exception e)
     {
         ExReports.reportFail(e.Message);
         throw;
     }
 }
예제 #13
0
파일: StorePage.cs 프로젝트: gshustin/GLSH2
 public void searchItem(string sItemName)
 {
     try
     {
         Common.waitForElementIsPresent("Search", "name", "s", Constants.TIME_OUT);
         SearchField.SendKeys(sItemName);
         ExReports.reportPass("'Search' field is filled");
         SearchField.SendKeys(Keys.Enter);
         ExReports.reportPass("'Enter' is pressed");
     }
     catch (Exception e)
     {
         ExReports.reportFail("Search item" + e.Message);
         throw;
     }
 }
예제 #14
0
파일: StorePage.cs 프로젝트: gshustin/GLSH2
        public void submitItem()
        {
            try
            {
                Common.waitForElementIsPresent("First name field", "xpath", "//input[@id='wpsc_checkout_form_2']", Constants.TIME_OUT);
                BtnSubmit.Click();
                ExReports.reportPass("'Purchase' button is clicked");

                Common.checkTextIsPresent("Thank you, your purchase is pending");
            }
            catch (Exception e)
            {
                ExReports.reportFail("Submit Item error" + e.Message);
                throw;
            }
        }
예제 #15
0
        public void fillUserFields()
        {
            try
            {
                FirstName.SendKeys("Gleb");
                ExReports.reportPass("'First name' field is filled");

                LastName.SendKeys("Shustin");
                ExReports.reportPass("'Last name' field is filled");
            }
            catch (Exception e)
            {
                ExReports.reportFail(e.Message);
                throw;
            }
        }
예제 #16
0
        public void chooseProfilePicture()
        {
            try
            {
                Common.createFile(sUploadPath);

                BtnChooseFile.Click();
                SendKeys.SendWait(sUploadPath);
                SendKeys.SendWait(@"{Enter}");

                ExReports.reportPass("File '" + UPLOAD_FILE_NAME + "' is uploaded");
            } catch (Exception e)
            {
                ExReports.reportFail("File '" + UPLOAD_FILE_NAME + "' is not uploaded. " + e.Message);
                throw;
            }
        }
예제 #17
0
 public void selectLinks()
 {
     try
     {
         PartialLink.Click();
         ExReports.reportPass("Partial Link is clicked");
         Link.Click();
         ExReports.reportPass("Link is clicked");
         Common.checkTextIsPresent("Burj Khalifa");
         ExReports.reportPass("Table page is loaded");
         pressBack();
         Common.checkTextIsPresent("Practice Automation Form");
         ExReports.reportPass("Form page is loaded");
     }
     catch (Exception e)
     {
         ExReports.reportFail(e.Message);
         throw;
     }
 }
예제 #18
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
        public void fillField(string sFieldName, string sType, string sObjectLocator, string sData)
        {
            try
            {
                switch (sType)
                {
                case "id":
                    waitForElementIsPresent(sFieldName, Constants.TIME_OUT, sObjectLocator);
                    getDriver.FindElement(By.Id(sObjectLocator)).SendKeys(sData);
                    ExReports.reportPass("Field '" + sFieldName + "' is filled");
                    break;

                case "name":
                    getDriver.FindElement(By.Name(sObjectLocator)).SendKeys(sData);
                    break;
                }
            }
            catch (Exception e)
            {
                ExReports.reportFail("Field '" + sFieldName + "' is not filled. " + e.Message);
                throw;
            }
        }
예제 #19
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
        public void clearField(string sFieldName, string sType, string sObjectLocator)
        {
            try
            {
                waitForElementIsPresent(sFieldName, Constants.TIME_OUT, sObjectLocator);
                switch (sType)
                {
                case "id":
                    getDriver.FindElement(By.Id(sObjectLocator)).Clear();
                    break;

                case "name":
                    getDriver.FindElement(By.Name(sObjectLocator)).Clear();
                    break;
                }
                ExReports.reportPass("Clear field - Field '" + sFieldName + "' is cleared");
            }
            catch (Exception e)
            {
                ExReports.reportFail("Field '" + sFieldName + "' is not cleared. " + e.Message);
                throw;
            }
        }
예제 #20
0
파일: StorePage.cs 프로젝트: gshustin/GLSH2
        public void checkOutItem()
        {
            try
            {
                Common.waitForElementIsPresent("Check out", "id", "header_cart", Constants.TIME_OUT);
                BtnCount.Click();
                ExReports.reportPass("'Check out' is clicked");

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(Constants.TIME_OUT));
                wait.Until(ExpectedConditions.TextToBePresentInElement(Count, getCount));
                ExReports.reportPass("1 item is on the card");

                //Common.waitForElementIsPresent("Continue button", "classname", "step2", Constants.TIME_OUT);
                Common.waitForElementIsPresent("Continue button", "xpath", "//span[contains(.,'Continue')]", Constants.TIME_OUT);
                BtnContinue.Click();
                ExReports.reportPass("'Continue' button is clicked");
            }
            catch (Exception e)
            {
                ExReports.reportFail("Check out item" + e.Message);
                throw;
            }
        }
예제 #21
0
파일: cmn.cs 프로젝트: gshustin/GLSH2
 public void clickPartialLink(string sLinkText)
 {
     getDriver.FindElement(By.PartialLinkText(sLinkText)).Click();
     ExReports.reportPass("Link is selected");
 }