- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How could I start a Selenium browser(like Firefox) minimized?
We can start the Selenium browser(like Firefox) in minimized mode. This will be achieved by taking the help of the Dimension class. We shall create an object of this class.
While creating the object , we shall pass the dimensions of the browser size as parameters to the Dimension class. Finally pass the object as parameter to the setSize method.
Syntax
Dimension s = new Dimension(100,200); driver.manage().window().setSize(s);
Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Dimension; public class FirefoxBrwSize{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); //implicit wait time driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); //set browser Dimension Dimension s = new Dimension(100,200); //set size to browser driver.manage().window().setSize(s); driver.get("https://www.tutorialspoint.com/index.htm"); // obtain window size System.out.println("Firefox browser size: " + driver. manage().window().getSize()); driver.quit(); } }
Output
Browser window −
Advertisements