示例#1
0
 public ContainerContext(ContainerBasePage container, ContainerContext parentContext = null)
 {
     _containingElement = container.Container; // the iframe
     _containerPage = container;
     _containerType = container.Type;
     _containerSwitchers = new Dictionary<ContainerType, Action<IWebDriver>>() 
     { 
         { ContainerType.Frame,   driver =>
                                      {
                                          driver.SwitchTo().Frame(_containingElement.Element); Log.Info(string.Format("Switched to Frame {0}", _containingElement.Identifier));
                                      }},
         { ContainerType.Alert,   driver => driver.SwitchTo().Alert()},
         { ContainerType.Window,  driver => driver.SwitchTo().Window(_containerPage.NewestWindowHandle)},
         { ContainerType.Element, driver => driver.SwitchTo().ActiveElement() }
     };
     _containerRestorers = new Dictionary<ContainerType, Action<IWebDriver>>() 
     { 
         { ContainerType.Frame, driver =>
             {
                 if (HasParentContext(parentContext))
                     SwitchToParentContext(parentContext);
                 else
                     SwitchToDefaultContent(driver);
             }
         },
         { ContainerType.Alert,   driver => { driver.SwitchTo().DefaultContent(); Log.Info("Switched to DefaultContent"); }}, //?
         { ContainerType.Window,  driver => driver.SwitchTo().Window(_containerPage.LastKnownWindowHandle)},
         { ContainerType.Element, driver => driver.SwitchTo().ActiveElement() }  //?
     };
     Switch();
 }
示例#2
0
 public ContainerBasePage(IWebDriver driver, ContainerType? containerType, string title = null, string url = null, ContainerWebElement parentContainer = null)
     : base(driver, title, url, parentContainer)
 {
     if (containerType != null) Type = containerType.Value;
     ActionsBeforeInit();
     InitContainerContext();
 }
示例#3
0
 public WebElement(string identifier, BasePage parentPage, Type nextPage = null, ContainerType?containerType = null, ContainerWebElement parentContainer = null)
 {
     Identifier            = identifier;
     ParentPage            = parentPage;
     NextPage              = nextPage;
     ParentContainer       = parentContainer;
     NextPageContainerType = containerType;
 }
示例#4
0
 public WebElement(string identifier, BasePage parentPage, Type nextPage = null, ContainerType? containerType = null, ContainerWebElement parentContainer = null)
 {
     Identifier = identifier;
     ParentPage = parentPage;
     NextPage = nextPage;
     ParentContainer = parentContainer;
     NextPageContainerType = containerType;
 }
示例#5
0
        public DropdownWebElement(string identifier, BasePage parentPage, ContainerType? containerType = null, ContainerWebElement container = null)
            : base(identifier, parentPage, null, containerType, container)
        {
            Selector = new Dictionary<SelectionKind, Action<object>>
            {
					{SelectionKind.Text, x => Select.SelectByText((string) x)},
					{SelectionKind.Value, x => Select.SelectByValue((string) x)},
					{SelectionKind.Index, x => Select.SelectByIndex((int) x)}
				};
        }
示例#6
0
        public T ClickAndTreatAlertAndOpenPopup(ContainerWebElement popupContainer, AlertResolveType alertResolveStatus = AlertResolveType.Accept, int timeToWaitForAlert = 60000)
        {
            ParentPage.LastKnownWindowHandle = ParentPage.Driver.CurrentWindowHandle;
            ParentPage.WindowHandlesSnapshot = ParentPage.Driver.WindowHandles;

            ClickAndTreatAlert(alertResolveStatus, timeToWaitForAlert, true);

            var page = GetPageInstance(popupContainer) as T;

            return(page);
        }
示例#7
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
        }
示例#8
0
        public BasePage(IWebDriver driver, string title, string url, ContainerWebElement parentContainer = null)
        {
            GetPageFromConfig();

            Driver = driver;
            Title = title;

            var containerBasePage = this as ContainerBasePage;
            if (containerBasePage != null) containerBasePage.Container = parentContainer;

            DefaultTimeout = TimeSpan.FromSeconds(30);
            DefaultPollingFrequency = TimeSpan.FromMilliseconds(250);
            Url = url;

            Load();

            StoreWindowHandle();
        }        
示例#9
0
        public BasePage(IWebDriver driver, string title, string url, ContainerWebElement parentContainer = null)
        {
            GetPageFromConfig();

            Driver = driver;
            Title  = title;

            var containerBasePage = this as ContainerBasePage;

            if (containerBasePage != null)
            {
                containerBasePage.Container = parentContainer;
            }

            DefaultTimeout          = TimeSpan.FromSeconds(30);
            DefaultPollingFrequency = TimeSpan.FromMilliseconds(250);
            Url = url;

            Load();

            StoreWindowHandle();
        }
示例#10
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);
 }
示例#11
0
 public ContainerBasePage(IWebDriver driver, ContainerType?containerType, string title = null, string url = null, ContainerWebElement parentContainer = null)
     : base(driver, title, url, parentContainer)
 {
     if (containerType != null)
     {
         Type = containerType.Value;
     }
     ActionsBeforeInit();
     InitContainerContext();
 }
示例#12
0
        public object GetPageInstance(ContainerWebElement popup)
        {
            var page = Activator.CreateInstance(NextPage, ParentPage.Driver, NextPageContainerType, null, popup) as BasePage;

            return page;
        }
示例#13
0
        public object GetPageInstance(ContainerWebElement popup)
        {
            var page = Activator.CreateInstance(NextPage, ParentPage.Driver, NextPageContainerType, null, popup) as BasePage;

            return(page);
        }
示例#14
0
 public ContainerWebElement(string identifier, BasePage parentPage, ContainerType containerType = ContainerType.Element, ContainerWebElement container = null)
     : base(identifier, parentPage, null, containerType, container)
 {
     Type = containerType;
     WindowName = null;
 }
示例#15
0
 public ContainerWebElement(string identifier, BasePage parentPage, ContainerType containerType = ContainerType.Element, ContainerWebElement container = null)
     : base(identifier, parentPage, null, containerType, container)
 {
     Type       = containerType;
     WindowName = null;
 }
示例#16
0
 public DropdownWebElement(string identifier, BasePage parentPage, ContainerType?containerType = null, ContainerWebElement container = null)
     : base(identifier, parentPage, null, containerType, container)
 {
     Selector = new Dictionary <SelectionKind, Action <object> >
     {
         { SelectionKind.Text, x => Select.SelectByText((string)x) },
         { SelectionKind.Value, x => Select.SelectByValue((string)x) },
         { SelectionKind.Index, x => Select.SelectByIndex((int)x) }
     };
 }
示例#17
0
 public LinkWebElement(string identifier, BasePage parentPage, ContainerType?containerType = null, ContainerWebElement containerWebElement = null)
     : base(identifier, parentPage, typeof(T), containerType, containerWebElement)
 {
     ParentContainer = containerWebElement;
 }