In this article we are going to see the functions for controlling a web browser
I am using C# code(JAVA will given later on) with dot net web driver.
-Maximizing Browser :
driver.Manage().Window.Maximize();
-Keep browser to specific position of the screen :
driver.Manage().Window.Position = new System.Drawing.Point(10,5);
In here (x,y)=(10,5)(distance from left upper corner)
-Keep browser in fixed size resolution :
driver.Manage().Window.Size = new System.Drawing.Size(640,480);
In here 640 is width and 480 is height.
-Open an URL in browser’s current tab:
driver.Navigate().GoToUrl("Site URL");
-Open Previous
URL in browser’s current tab from the history (like as back button of the browser) :
driver.Navigate().Back();
-Open Next URL in browser’s current tab from the history (like as Next button of the browser):
driver.Navigate().Forward();
- Refresh current page
driver.Navigate().Refresh();
- Refresh current page
driver.Navigate().Refresh();
-To start Firefox browser with specific profile( i.e.- Tester creates new profile or use default profile to test for default settings and initiations.)
private static FirefoxProfile myprofile = new FirefoxProfile("path of the profile directory");
private IWebDriver driver = new FirefoxDriver(myprofile);
In my case the path was @"C:\Users\shantonu\AppData\Local\Mozilla\Firefox\Profiles"
-To get the source of the page last loaded by the browser
driver.PageSource
Note : This will give page source string. We can compare with tested html.
These are some mostly use functions. I will add more incrementally.
Note : This will give page source string. We can compare with tested html.
These are some mostly use functions. I will add more incrementally.
... To be continued...
No comments:
Post a Comment