Наследование: IBrowserFacade
Пример #1
0
        public void Setup()
        {
            #region IWebDriver Setup
            IList<Cookie> cookies = new List<Cookie>();
            cookies.Add(new Cookie("s_cc","=true"));
            _web = Substitute.For<IWebDriver>();
            _web.Manage().Cookies.AllCookies.Returns(new ReadOnlyCollection<Cookie>(cookies));
            #endregion
            #region IJavascriptExecutor Setup
            IList<object> _dimensions = new List<object>(new object[] {800,600});
            var _dimensionsCollection = new ReadOnlyCollection<object>(_dimensions);
            _js = Substitute.For<IJavaScriptExecutor>();
            _js.ExecuteScript(Arg.Is(Javascript.Viewport)).Returns(_dimensionsCollection);
            IList<object> _browserInfo = new List<object>(new object[] { "firefox", "10.1", "WINDOWS" });
            var _browserInfoCollection = new ReadOnlyCollection<object>(_browserInfo);
            _js.ExecuteScript(Arg.Is(Javascript.Info)).Returns(_browserInfoCollection);
            IList<object> _resources = new List<object>(new[]
            {
                new Resource
                {
                    Uri = "http://c.mfcreativedev.com/webparts/banner/Banner.js?v=c5589edb",
                    StatusCode = HttpStatusCode.OK,
                    StatusDescription = "OK",
                    Headers = new List<string>
                    {
                        "Content-Length:194",
                        "Cache-Control:public, must-revalidate",
                        "Content-Type:application/x-javascript",
                        "Date:Thu, 20 Sep 2012 17:15:03 GMT",
                        "ETag:JsJt380DknGc4kAEEn76og=="
                    }
                }
            });

            var _resourcesCollection = new ReadOnlyCollection<object>(_resources);
            _js.ExecuteScript(Arg.Is(Javascript.Resources)).Returns(_resourcesCollection);
            #endregion
            #region ITakesScreenshot Setup
            _ss = Substitute.For<ITakesScreenshot>();
            var bp = ImageUtil.ImageToBase64(new Bitmap(10, 10), ImageFormat.Png);
            _ss.GetScreenshot().Returns(new Screenshot(bp));
            #endregion
            _request = new Request
            {
                Url = "http://www.google.com/",
                Browser = "firefox"
            };
            _facade = new WebDriverFacade(_web,_request,_ss,_js);
        }
Пример #2
0
        public static IBrowserFacade CreateFacade(IWebDriver webDriver, Request request)
        {
            IBrowserFacade facade;

            if (request.Browser == null || request.Browser.ToLower() != "phantomjs")
            {
                facade = new WebDriverFacade(webDriver, request);
            }
            else
            {
                facade = new PhantomJsFacade(request);
            }

            return facade;
        }
Пример #3
0
        public static IBrowserFacade CreateFacade(Request request)
        {
            IBrowserFacade facade;

            if (request.Browser == null || request.Browser.ToLower() != "phantomjs")
            {
                var config = GetConfig(request);
                var web = GetWebDriver(config);
                facade = new WebDriverFacade(web, request);
            }
            else
            {
                facade = new PhantomJsFacade(request);
            }

            return facade;
        }