コード例 #1
0
        protected virtual T InstanceOf <T>(NavigateBy navigation) where T : SeleniqBase, new()
        {
            NavUrlAttribute attrType;

            switch (navigation)
            {
            case NavigateBy.PageUrl:
                attrType = typeof(T).GetCustomAttribute <PageUrlAttribute>();
                break;

            case NavigateBy.ElementUrl:
                attrType = typeof(T).GetCustomAttribute <ElementUrlAttribute>();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(navigation), navigation, null);
            }

            if (attrType == null)
            {
                throw new SeleniqException($"{typeof(T).Name} class doesn't have {navigation} attribute");
            }

            var pageUrl = attrType.Url;


            if (!pageUrl.StartsWith("http"))
            {
                BaseUrl.CheckNotNullOrEmpty("BaseUrl", "BaseUrl property is not found on app.config");
                pageUrl = string.Concat(BaseUrl, pageUrl);
            }
            Driver.Navigate().GoToUrl(pageUrl);

            return(new T());
        }
コード例 #2
0
        private void NavigateBy_DropDown(object sender, EventArgs e)
        {
            int      width = 0;
            Graphics g     = NavigateBy.CreateGraphics();
            Font     font  = NavigateBy.Font;

            foreach (string s in NavigateBy.Items)
            {
                int w = (int)g.MeasureString(s, font).Width;
                if (w > width)
                {
                    width = w;
                }
            }
            int vert_scroll_bar_width = (NavigateBy.Items.Count > NavigateBy.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0;

            NavigateBy.DropDownWidth = width + vert_scroll_bar_width + 10;
        }