コード例 #1
0
		internal static IWebElement PeekElement(this IWebDriver driver, WebElement webElement, int seconds = 1)
		{
            using (ImplicitWaitContext.Create(TimeSpan.FromSeconds(seconds)))
            {
                return webElement.Element;
            }
		}
コード例 #2
0
ファイル: Globals.cs プロジェクト: vlatkodimeski/test1
        public static bool RegisterTrigger(Type page, WebElement webElement)
        {
            lock (NavigationTriggers)
            {
                var newlyAdded = !NavigationTriggers.ContainsKey(page);

                NavigationTriggers[page] = webElement;

                return newlyAdded;
            }
        }
コード例 #3
0
        public MyBeazleyLoginPage(IWebDriver driver, string title = null, string url = null, ContainerWebElement parentContainer = null)
            : base(driver, "myBeazley UAT", url, parentContainer)
        {            
            //Beazley Link
            LinkLogoBeazley = new LinkWebElement<MyBeazleyLoginPage>("LinkLogoBeazley", this);

            //Privacy links - RB_PrivacyLinks
            PrivacyLinks = new LinkWebElement<MyBeazleyLoginPage>("PrivacyLinks", this);

            //Privacy links - RB_PrivacyLinks
            TcPrivacyLinks = new LinkWebElement<MyBeazleyLoginPage>("TC_PrivacyLinks", this);

            //Privacy links - RB_PrivacyLinks
            PcPrivacyLinks = new LinkWebElement<MyBeazleyLoginPage>("PC_PrivacyLinks", this);

            //Header logo
            HeaderLogo = new WebElement("HeaderLogo", this);

            //myBeazley right image
            BeazleyRightImage = new LinkWebElement<MyBeazleyLoginPage>("BeazleyRightImage", this);

            //Sign in title label
            TitleLabelLogin = new WebElement("TitleLabelLogin", this);

            //Sign in Submit
            BtnSignIn = new LinkWebElement<MyBeazleyHomePage>("BtnSignIn", this);

            //Sign in Submit
            FailedBtnSignIn = new WebElement("BtnSignIn", this);

            //Username field and label
            //UsernameField = new WebElement(Locator.Create(With.Id, "UsernameField"), this);
            UsernameField = new WebElement("UsernameField", this);
            UsernameLabel = new WebElement("UsernameLabel", this);

            //Password Field and label
            PasswordField = new WebElement("PasswordField", this);
            PasswordLabel = new WebElement("PasswordLabel", this);

            //Forgotten your password?
            ForgottenPassword = new LinkWebElement<MyBeazleyLoginPage>("ForgottenPassword", this);

            //DdlSelectLanguage = new SelectWebElement(Locator.Create(With.Id, "searchlang"), this);
            LanguageLocator = new WebElement("LanguageLocator", this);
            ErrorLoginMessage = new WebElement("ErrorLoginMessage", this);
            EmptyUsernameError = new WebElement("EmptyUsernameError", this); //loginerror
        }
コード例 #4
0
		public static Func<IWebDriver, bool> ExpectedConditions_ElementExists(WebElement webElement)
		{
			return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_ElementExists",
									   (seleniumDriver, elementLocator, actionName) =>
										   {
												IWebElement targetElement = driver.PeekElement(webElement);

												var elementWasFound = targetElement != null;

												if (!elementWasFound)
												{
													LogElemNotFound();
												}

												Log.Info(string.Format("{0} {1} = {2}", actionName, webElement.Identifier, elementWasFound));

												return elementWasFound;
										   });
		}
コード例 #5
0
		public static Func<IWebDriver, bool> ExpectedConditions_ElementIsNotVisible(WebElement webElement)
		{
			return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_ElementIsNotVisible",
									   (seleniumDriver, elementLocator, actionName) =>
										   {
												IWebElement targetElement = driver.PeekElement(webElement);

												if (targetElement == null)
												{
													LogElemNotFound();
													return false;
												}
													
												bool result = !targetElement.Displayed;
												Log.Info(string.Format("{0} {1} = {2}", actionName, webElement.Identifier, result));

												return result;
										   });
		}
コード例 #6
0
		public static Func<IWebDriver, bool> ExpectedConditions_ElementIsVisible(WebElement webElement)
		{
			return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_ElementIsVisible",
									   (seleniumDriver, elementLocator, actionName) =>
										   {
												IWebElement targetElement = driver.PeekElement(webElement);

												if (targetElement == null)
												{
													LogElemNotFound();
													return false;
												}
												bool result;
												using (ImplicitWaitContext.Create(TimeSpan.FromSeconds(1)))
												{
                                                    result = targetElement.Displayed;
												}
												Log.Info(string.Format("{0} {1} = {2}", actionName, webElement.Identifier, result));

												return result;
										   });
		}
コード例 #7
0
 public MyBeazleyHomePage(IWebDriver driver, string title, string url, ContainerWebElement parentContainer = null)
     : base(driver, "myBeazley UAT - Quotes", url, parentContainer)                  //ova e title
 {
     SignOutButton = new LinkWebElement<MyBeazleyLoginPage>("logoff", this);
 }
コード例 #8
0
        public ElementNotPresentException(WebElement webElement)
            : base(string.Format("Element {0} no longer exists on page", webElement))
        {

        }
コード例 #9
0
		public static WaitElementHelper Element(WebElement element)
		{
			return new WaitElementHelper(element);
		}
コード例 #10
0
		public static Func<IWebDriver, bool> ExpectedConditions_TextNotPresent(WebElement webElement, string text)
		{
            return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_TextPresent",
									   (seleniumDriver, elementLocator, actionName) =>
										   {
												IWebElement targetElement = driver.PeekElement(webElement);

												var elementDoesNotExist = targetElement == null;

												if (elementDoesNotExist)
												{
													LogElemNotFound();
													throw new ElementNotPresentException(webElement);
												}

												string elementValue = targetElement.GetAttribute("value") ??
																		targetElement.Text ?? string.Empty;
												bool textIsNotPresent =
													!elementValue.ToLowerInvariant().Contains(text.ToLowerInvariant());

												Log.Info(string.Format("{0} -> {1} value {2} contains {3} = {4}",
                                                                        actionName, webElement.Identifier, elementValue, text,
																		textIsNotPresent));

												return textIsNotPresent;
										   });
		}
コード例 #11
0
		public static Func<IWebDriver, bool> ExpectedConditions_ElementIsNotEnabled(WebElement webElement)
		{

            return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_ElementIsExists",
									   (seleniumDriver, elementLocator, actionName) =>
									   {
											IWebElement targetElement = driver.PeekElement(webElement);

											var elementDoesNotExist = targetElement == null;

											if (elementDoesNotExist)
											{
												LogElemNotFound();
												return false;
											}

                                            Log.Info(string.Format("Chek if enabled for : {0}", webElement.Identifier));
											var disabledAttributeValue = targetElement.GetAttribute("disabled");
											if (!String.IsNullOrEmpty(disabledAttributeValue) && (disabledAttributeValue.Equals("true")))
												return true;
											bool notEnabled = !targetElement.Enabled;
                                            Log.Info(string.Format("{0} {1} = {2}", actionName, webElement.Identifier, notEnabled));
											return notEnabled;
									   });
		}
コード例 #12
0
		public static Func<IWebDriver, bool> ExpectedConditions_IsVisibleAndEnabled(WebElement webElement)
		{
            return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_IsVisibleAndEnabled",
									   (seleniumDriver, elementLocator, actionName) =>
									   {
											IWebElement targetElement = driver.PeekElement(webElement);

											var elementExists = targetElement != null;

                                            Log.Info(string.Format("{0} {1} = {2}", actionName, webElement.Identifier, elementExists));

											if (!elementExists)
											{
												LogElemNotFound();
												return false;
											}

                                            Log.Info(string.Format("VisibleEnabled test for {0}", webElement.Identifier));
											var displayed = targetElement.Displayed;
											bool enabled;
											var disabledAttributeValue = targetElement.GetAttribute("disabled");
											if (!String.IsNullOrEmpty(disabledAttributeValue) && (disabledAttributeValue.Equals("true")))
												enabled = false;
											else
												enabled = targetElement.Enabled;

											Log.Info(string.Format("VisibleEnabled test - displayed:{0}, enabled:{1}", displayed, enabled));
											var result = displayed && enabled;

                                            Log.Info(String.Format("{0} -> visibleEnabled test for {1} was {2}!", actionName, webElement.Identifier, result ? "successful" : "not successful"));

											return result;
										});
		}
コード例 #13
0
		public static Func<IWebDriver, bool> ExpectedConditions_IsNotStale(WebElement webElement)
		{
			return driver => TryAction(driver, webElement.Identifier, "ExpectedConditions_IsNotStale",
									   (seleniumDriver, elementLocator, actionName) =>
										   {
											   IWebElement targetElement = driver.PeekElement(webElement);

											   var elementExists = targetElement != null;

											   Log.Info(string.Format("{0} {1} = {2}", actionName, webElement.Identifier, elementExists));

											   if (!elementExists)
											   {
												   LogElemNotFound();
												   return false;
											   }


											   bool result;
											   switch (targetElement.TagName.ToLower())
											   {
												   case "input":
												   case "a":
												   case "img":
												   case "select":
												   case "option":
												   case "button":
												   case "tr":
												   case "td":
													   {
														   Log.Info(string.Format("Stale test for {0}", webElement.Identifier));
														   var displayed = targetElement.Displayed;
														   bool enabled;
														   var disabledAttributeValue = targetElement.GetAttribute("disabled");
														   if (!String.IsNullOrEmpty(disabledAttributeValue) && (disabledAttributeValue.Equals("true")))
															   enabled = false;
														   else
															   enabled= targetElement.Enabled;
														   Log.Info(string.Format("Stale test - displayed:{0}, enabled:{1}", displayed, enabled));
														   result = displayed && enabled;
													   }
													   break;
												   default:
													   {
														   // stale test for non-buttons
														   Log.Info("Stale test for non-clickable element.");
														   targetElement.Click();
														   result = true;
													   }
													   break;
											   }

											   Log.Info(String.Format("{0} -> stale test for {1} was {2}!", actionName, webElement.Identifier, result ? "successful" : "not successful"));

											   return result;
										   });
		}
コード例 #14
0
ファイル: WaitHelper.cs プロジェクト: vlatkodimeski/test1
 public WaitElementHelper(WebElement element)
     : base(true)
 {
     WebElement = element;
 }