public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browserView.Browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView.GetComponent()); this.Controls.Add((Control)browserView.GetComponent()); DOMEventHandler domEvent = delegate(object sender, DOMEventArgs e) { DOMEventType eventType = e.Type; Console.Out.WriteLine("handleEvent = " + eventType); }; browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; documentElement.AddEventListener(DOMEventType.OnClick | DOMEventType.OnMouseDown | DOMEventType.OnMouseUp | DOMEventType.OnKeyDown, domEvent, false); } }; browserView.Browser.LoadURL("http://www.teamdev.com"); }
public void GivenIAmAlreadyInResetPasswordPage() { BrowserFactory.InitBrowser(); BrowserFactory.LoadApplication(); Page.Home.SelectLogin(); Page.Login.GoFindPassword(); }
public void GivenIAmAlreadyInRegisterPage() { BrowserFactory.InitBrowser(); BrowserFactory.LoadApplication(); Page.Home.SelectLogin(); Page.Login.GoRegisterPage(); }
private void InitBrowser() { try { string path = Assembly.GetExecutingAssembly().Location; string appDir = Path.GetDirectoryName(path); #if DEBUG LoggerProvider.Instance.LoggingEnabled = true; LoggerProvider.Instance.FileLoggingEnabled = true; string logsDir = Path.Combine(appDir, "Logs"); if (!Directory.Exists(logsDir)) { Directory.CreateDirectory(logsDir); } LoggerProvider.Instance.OutputFile = Path.Combine(logsDir, $"DotNetBrowser-{new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local)}.log"); #endif var uri = new Uri(Path.Combine(appDir, @"PokeEase\index.html")); var browser = BrowserFactory.Create(BrowserType.LIGHTWEIGHT); webView = new WPFBrowserView(browser); browserLayout.Children.Add((UIElement)webView.GetComponent()); webView.Browser.LoadURL(uri.ToString()); } catch { NecroBot.Logic.Logging.Logger.Write("DotNetBrowser has encountered an issue, and has been shut down to prevent a crash", LogLevel.Warning); Settings.Default.BrowserToggled = false; Settings.Default.Save(); BrowserSync(false); } }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { //Event for detecting if the page is loaded ManualResetEvent loadedEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += (finishSender, finishArgs) => { if (finishArgs.IsMainFrame) { Console.WriteLine(browser.GetHTML()); loadedEvent.Set(); } }; //Registering the handler for the specified protocol browser.Context.ProtocolService.Register("https", new HttpsHandler()); //Loading Url with the same protocol as registered browser.LoadURL("https://request.url"); //Waiting the page loading loadedEvent.WaitOne(); } Console.ReadKey(); }
protected void OnInitialized() { var switches = DotNetBrowserSwitches.Create(BrowserType); BrowserPreferences.SetChromiumSwitches(switches.ToArray()); _path = GetOrCreateContextParamsPath(); _browserContext = new BrowserContext(new BrowserContextParams(_path)); browser = BrowserFactory.Create(_browserContext, BrowserType); browser.Preferences.AllowDisplayingInsecureContent = false; browser.Preferences.AllowRunningInsecureContent = false; browser.Preferences.AllowScriptsToCloseWindows = false; browser.Preferences.ApplicationCacheEnabled = false; browser.Preferences.DatabasesEnabled = false; browser.Preferences.LocalStorageEnabled = false; browser.Preferences.PluginsEnabled = false; browser.Preferences.TransparentBackground = true; browser.Preferences.UnifiedTextcheckerEnabled = false; browser.Preferences.WebAudioEnabled = false; browser.ZoomEnabled = true; browser.DialogHandler = this; browser.LoadHandler = this; browser.Context.NetworkService.ResourceHandler = this; browser.RenderGoneEvent += Browser_RenderGoneEvent; browser.ScriptContextCreated += Browser_ScriptContextCreated; }
static void Main(string[] args) { Browser browser = BrowserFactory.Create(); // Suppress/filter all incoming and outgoing cookies. browser.Context.NetworkService.NetworkDelegate = new MyNetworkDelegate(); }
static void Main(string[] args) { Browser browser = BrowserFactory.Create(); JSValue document = browser.ExecuteJavaScriptAndReturnValue("document"); if (document.IsObject()) { // document.title = "New Title" document.AsObject().SetProperty("title", "New Title"); // document.write("Hello World!") JSValue write = document.AsObject().GetProperty("write"); if (write.IsFunction()) { write.AsFunction().Invoke(document.AsObject(), "Hello World!"); } } JSValue documentContent = browser.ExecuteJavaScriptAndReturnValue("document.body.innerText"); if (documentContent.IsString()) { Console.Out.WriteLine("New content: " + documentContent.GetString()); } }
public VkPhoneConfirmForm(WebProxy proxy) { InitializeComponent(); BrowserView browser = null; if (proxy != null) { var dataDir = Path.GetFullPath("chromium-data"); var contextParams = new BrowserContextParams(dataDir); var proxyRules = "https=" + proxy.Address.Host + ":" + proxy.Address.Port; contextParams.ProxyConfig = new CustomProxyConfig(proxyRules); browser = new WinFormsBrowserView( BrowserFactory.Create( new BrowserContext(contextParams), BrowserType.LIGHTWEIGHT)); } else { browser = new WinFormsBrowserView(); } wb = (Control)browser; this.Controls.Add(wb); wb.Dock = DockStyle.Fill; browser.Browser.LoadURL("https://vk.com"); }
public void Advanced_Search_By_Role_Filters_Results() { using (var driver = BrowserFactory.Create()) { SignInAsAdmin(driver); driver.FindElement(By.PartialLinkText("Users")).Click(); driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1); driver.FindElement(By.CssSelector(".advanced")).Click(); driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count > 0); (driver as IJavaScriptExecutor).ExecuteScript(@"$('select[name=""Role""]').val('Administrator')"); ModalHelper.ClickPrimary(driver); driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count == 0); var rows = driver.FindElementsByCssSelector(".table tbody tr"); var filtered = true; foreach (var el in rows) { var td = el.FindElement(By.CssSelector("td:nth-child(3)")); if (td.Text != "Administrator") { filtered = false; } } Assert.IsTrue(filtered); } }
public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMNode root = document.GetElementById("root"); DOMNode textNode = document.CreateTextNode("Some text"); DOMElement paragraph = document.CreateElement("p"); paragraph.AppendChild(textNode); root.AppendChild(paragraph); } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
public WindowMain() { BrowserContext browserContext = BrowserContext.DefaultContext; Browser browser = BrowserFactory.Create(browserContext); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = browser.GetDocument(); XPathResult result = document.Evaluate("count(//div)"); // If the expression is not a valid XPath expression or the document // element is not available, we'll get an error. if (result.IsError) { Console.WriteLine("Error: " + result.ErrorMessage); return; } // Make sure that result is a number. if (result.IsNumber) { Console.WriteLine("Result: " + result.Number); } } }; browserView = new WPFBrowserView(browser); Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { // Wait until main document of the web page is loaded completely. if (e.IsMainFrame) { // Execute JavaScript code and get return value from JavaScript. JSValue returnValue = e.Browser.ExecuteJavaScriptAndReturnValue("document.title"); // Make sure that return value is a string. if (returnValue.IsString()) { // Extract string value from JSValue and write it to Console. Console.Out.WriteLine("The \"document.title\" JavaScript code returns \"" + returnValue.GetString() + "\""); } waitEvent.Set(); } }; browser.LoadURL("http://www.google.com"); waitEvent.WaitOne(); } }
public void BeforeEachTestCase() { BrowserFactory.InitBrowser("Chrome"); BrowserFactory.LoadApplication(ConfigurationManager.AppSettings["URL"]); Page.Login.Login(); }
public void TestMethod1() { var browser = BrowserFactory.Launch(BrowserType.InternetExplorer); var browser1 = BrowserFactory.Launch(BrowserType.InternetExplorer); var enterYourSearchTermEditField = browser.Describe <IEditField>(new EditFieldDescription { Name = @"q", Placeholder = string.Empty, TagName = @"INPUT", Type = @"search" }); enterYourSearchTermEditField.SetValue("hello"); var webSearchButton = browser.Describe <IButton>(new ButtonDescription { ButtonType = @"submit", Name = @"web search", TagName = @"BUTTON" }); webSearchButton.Click(); var browser2 = BrowserFactory.Launch(BrowserType.InternetExplorer); var browser3 = BrowserFactory.Launch(BrowserType.InternetExplorer); }
public GoogleHomePage(string browserName) { // Initialize (and save) a driver instance for the selected browser this._driver = BrowserFactory.OpenBrowserInstanceFor(browserName); //this._driver = BrowserFactory.Drivers[browserName.ToUpper()]; PageFactory.InitElements(this._driver, this); }
public void LogoutPositiveTests() { var dashboard = new DashboardPage(); dashboard.Logout(); Assert.AreEqual(BrowserFactory.QuantumReverseUrl + "account/login", BrowserFactory.GetDriverUrl()); }
public void Initialize() { BrowserFactory.InitBrowser("Chrome"); BrowserFactory.GetDriver.Manage().Window.Maximize(); BrowserFactory.GoToURL(ConfigurationManager.AppSettings["URL"]); scenario = featureName.CreateNode <Scenario>(ScenarioContext.Current.ScenarioInfo.Title); }
static void Main(string[] args) { SdkConfiguration config = new SdkConfiguration(); config.ServerAddress = new Uri("ws://*****:*****@gmail.com"); cretepage.tbphone.SetValue("976812570"); cretepage.tbaddress.SetValue("Airoli NaviMumbai"); cretepage.btnsubmit.Click(); }
public void LaunchTheApplicationAndNavigateURL() { browserFactory = new BrowserFactory(); driver = browserFactory.SelectBrowseForExecution(); browserFactory.LoadApplication(driver, "https://www.amazon.in"); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(8); }
public void Setup() { BrowserFactory fact = new BrowserFactory(); driver = fact.InitBrowser("chrome"); driver.Url = Config.URL; }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMSelectElement select = (DOMSelectElement)document.GetElementById("select-tag"); select.Value = "opel"; } }; browserView.Browser.LoadHTML("<html><body><select id='select-tag'>\n" + " <option value=\"volvo\">Volvo</option>\n" + " <option value=\"saab\">Saab</option>\n" + " <option value=\"opel\">Opel</option>\n" + " <option value=\"audi\">Audi</option>\n" + "</select></body></html>");; }
private static RemoteWebDriver CreateDriver() { var browser = BrowserFactory.GetBrowser(Configuration.Browser); var useSauceLabs = Configuration.UseSauceLabs; var useSeleniumGrid = Configuration.UseSeleniumGrid; var nodePlatform = Configuration.NodePlatform; var capabilities = browser.Capabilities(useSauceLabs, useSeleniumGrid, nodePlatform); if (useSauceLabs) { var user = Configuration.SauceLabsUser; var key = Configuration.SauceLabsKey; capabilities.SetCapability("username", user); capabilities.SetCapability("accessKey", key); return(new RemoteWebDriver(new Uri($"http://ondemand.saucelabs.com:80/wd/hub"), capabilities)); } if (useSeleniumGrid) { var url = new Uri(Configuration.HubUrl); return(new RemoteWebDriver(url, capabilities)); } return((RemoteWebDriver)browser.Instance); }
public Form1() { InitializeComponent(); browserView = new WinFormsBrowserView(BrowserFactory.Create(BrowserType.LIGHTWEIGHT)); Controls.Add((Control)browserView); browserView.Browser.LoadURL("http://www.google.com"); }
public static RemoteWebDriver CreateDriver() { var browser = BrowserFactory.GetBrowser(ConfigurationManager.AppSettings["Browser"]); var useSauceLabs = bool.Parse(ConfigurationManager.AppSettings["UseSauceLabs"]); var useSeleniumGrid = bool.Parse(ConfigurationManager.AppSettings["UseSeleniumGrid"]); var nodePlatform = ConfigurationManager.AppSettings["NodePlatform"]; var capabilities = browser.Capabilities(useSauceLabs, useSeleniumGrid, nodePlatform); if (useSauceLabs) { var user = ConfigurationManager.AppSettings["SauceLabsUser"]; var key = ConfigurationManager.AppSettings["SauceLabsKey"]; capabilities.SetCapability("username", user); capabilities.SetCapability("accessKey", key); return(new RemoteWebDriver(new Uri($"http://ondemand.saucelabs.com:80/wd/hub"), capabilities)); } if (useSeleniumGrid) { var url = new Uri(ConfigurationManager.AppSettings["HubUrl"]); return(new RemoteWebDriver(url, capabilities)); } return((RemoteWebDriver)browser.Instance); }
public void Test() { // BrowserFactory.InitBrowser("Firefox"); BrowserFactory.LoadApplication(ConfigurationManager.AppSettings["URL"]); Page.Home.ClickOnMyAccount(); Page.Login.LoginToApplication("LoginTest"); }
public void GivenIAmAlreadyInLoginPage() { BrowserFactory.InitBrowser(); BrowserFactory.LoadApplication(); Page.Home.SelectLogin(); Page.Login.ValidLogin(); }
public bool SubmitCookiesNotAccepted(BrowserFactory.BrowserType browserType) { IWebDriver driver = BrowserFactory.StartBrowser(browserType, RegisterPage.url); var registerPage = new RegisterPage(driver); PageFactory.InitElements(driver, registerPage); registerPage.Login.SendKeys("cookieTest"); registerPage.Email.SendKeys("*****@*****.**"); registerPage.Password.SendKeys("password1"); registerPage.PasswordConfirmation.SendKeys("password1"); registerPage.PasswordConfirmation.Submit(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); // WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); // wait.Until(((IJavaScriptExecutor) driver).ExecuteScript("return document.readyState").Equals("complete")); try { IWebElement message = driver.FindElement(By.XPath("//*[@id=\"successMsg\"]")); Debug.WriteLine("Page title = " + message); driver.Close(); driver.Dispose(); return(true); } catch (Exception e) { driver.Close(); driver.Dispose(); Debug.WriteLine("Register Not Succeeded." + "\n" + e.ToString()); return(false); } }
public BrowserForm(string url, int height = 800, int width = 1100, string initialState = "{}") { // InitializeComponent(); this.Height = height; this.Width = width; browser = BrowserFactory.Create(BrowserType.LIGHTWEIGHT); BrowserView = new WinFormsBrowserView(browser); ManualResetEvent waitEvent = new ManualResetEvent(false); BrowserView.DocumentLoadedInMainFrameEvent += delegate (object sender, LoadEventArgs e) { waitEvent.Set(); }; BrowserView.Dock = DockStyle.Fill; Controls.Add(BrowserView); BrowserView.Browser.LoadURL(url); waitEvent.WaitOne(); Del handler = CloseWindow; BrowserView.ScriptContextCreated += delegate (object sender, ScriptContextEventArgs e) { jsStateValue = browser.ExecuteJavaScriptAndReturnValue("window"); jsStateValue.AsObject().SetProperty("UiBrowserState", new UiBrowserState(handler, initialState)); }; // Dispose Browser instance. //BrowserView.Dispose(); }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { // Wait until main document of the web page is loaded completely. if (e.IsMainFrame) { SearchParams request = new SearchParams("find me"); // Find text from the beginning of the loaded web page. SearchResult result = browser.FindText(request); Console.Out.WriteLine(result.CurrentMatch + "/" + result.NumberOfMatches); // Find the same text again from the currently selected match. result = browser.FindText(request); Console.Out.WriteLine(result.CurrentMatch + "/" + result.NumberOfMatches); waitEvent.Set(); } }; browser.SetSize(700, 500); browser.LoadHTML("<html><body><p>Find me</p><p>Find me</p></body></html>"); waitEvent.WaitOne(); Thread.Sleep(5000); } }