ਵੈਬਡਰਾਈਵਰ ਵਿੱਚ ਬਰਾ Browਜ਼ਰ ਵਿੰਡੋ ਦਾ ਆਕਾਰ ਕਿਵੇਂ ਬਦਲੋ

ਬ੍ਰਾiumਜ਼ਰ ਵਿੰਡੋ ਨੂੰ ਸੇਲੀਨੀਅਮ ਵੈਬਡਰਾਈਵਰ ਨਾਲ ਮੁੜ ਆਕਾਰ ਕਿਵੇਂ ਦੇਣਾ ਹੈ? ਇੱਥੇ, ਅਸੀਂ ਤਿੰਨ ਵੱਖੋ ਵੱਖਰੇ ਤਰੀਕਿਆਂ ਵੱਲ ਵੇਖਦੇ ਹਾਂ ਜੋ ਅਸੀਂ ਵੈਬਡਰਾਈਵਰ ਵਿੱਚ ਬ੍ਰਾ browserਜ਼ਰ ਵਿੰਡੋ ਨੂੰ ਮੁੜ ਅਕਾਰ ਦੇ ਸਕਦੇ ਹਾਂ.

ਜਦੋਂ ਵੀ ਵੈਬਡਰਾਈਵਰ ਬ੍ਰਾ browserਜ਼ਰ ਨੂੰ ਚਾਲੂ ਕਰਦਾ ਹੈ, ਤਾਂ ਇਹ ਇਸਨੂੰ ਡਿਫਾਲਟ ਸੈਟਿੰਗਜ਼ ਨਾਲ ਅਰੰਭ ਕਰਦਾ ਹੈ. ਕਈ ਵਾਰ ਬਰਾ theਜ਼ਰ ਵਿੰਡੋ ਨੂੰ ਮੁੜ ਅਕਾਰ ਦੇਣ ਦੀ ਜ਼ਰੂਰਤ ਹੁੰਦੀ ਹੈ, ਖ਼ਾਸਕਰ ਜਦੋਂ ਅਸੀਂ ਜਵਾਬਦੇਹ ਵੈਬ ਸਾਈਟਾਂ ਦੀ ਜਾਂਚ ਕਰ ਰਹੇ ਹਾਂ ਕਿਉਂਕਿ ਸਾਨੂੰ ਇਹ ਵੇਖਣ ਲਈ ਜਾਂਚ ਕਰਨ ਦੀ ਜ਼ਰੂਰਤ ਹੁੰਦੀ ਹੈ ਕਿ ਜਦੋਂ ਅਸੀਂ ਬ੍ਰਾ browserਜ਼ਰ ਵਿੰਡੋ ਦਾ ਆਕਾਰ ਬਦਲਦੇ ਹਾਂ ਤਾਂ ਪੰਨੇ ਦੇ ਵੱਖਰੇ ਤੱਤ ਕਿਵੇਂ ਪੇਸ਼ ਹੁੰਦੇ ਹਨ.

ਵੈਬਡਰਾਈਵਰ ਕੋਲ ਸੁਵਿਧਾਜਨਕ methodsੰਗ ਅਤੇ ਵੱਖੋ ਵੱਖਰੇ waysੰਗ ਹਨ ਜੋ ਸਾਨੂੰ ਬ੍ਰਾ browserਜ਼ਰ ਵਿੰਡੋ ਨੂੰ ਮੁੜ ਅਕਾਰ ਦੇਣ ਦੀ ਆਗਿਆ ਦੇ ਸਕਦੇ ਹਨ.




ਬਰਾDਜ਼ਰ ਵਿੰਡੋ ਨੂੰ ਵੈੱਬ ਡਰਾਇਵਰ ਵਿੱਚ ਮੁੜ ਆਕਾਰ ਦਿਓ

ਜਾਵਾ ਮਾਪ ਵਰਤ ਕੇ

import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.Dimension; public class BrowserOperations {
WebDriver driver;
//this will open browser with default size
public void launchBrowser() {
driver = new FirefoxDriver();
}
public void resizeBrowser() {
Dimension d = new Dimension(800,480);
//Resize current window to the set dimension
driver.manage().window().setSize(d);
} }

ਜਾਵਾ ਕਰੋਮ ਵਿਕਲਪਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦਿਆਂ


import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.DesiredCapabilities; public class BrowserOperations {
public static void main(String[] args) {
System.setProperty('webdriver.chrome.driver';,
'/path/to/chromedriver');

ChromeOptions options = new ChromeOptions();
options.addArguments('window-size=800,480');

DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, options);

//this will open chrome with set size
WebDriver driver = new ChromeDriver(capabilities);

driver.get('https://www.testingexcellence.com/');
} }

ਜੇ ਤੁਸੀਂ ਬਰਾ browserਜ਼ਰ ਵਿੰਡੋ ਨੂੰ ਸਕ੍ਰੀਨ ਦੀ ਅਧਿਕਤਮ ਚੌੜਾਈ ਅਤੇ ਉਚਾਈ ਤੱਕ ਵਧਾਉਣਾ ਚਾਹੁੰਦੇ ਹੋ, ਤਾਂ ਤੁਸੀਂ ਸਿਰਫ ਵੱਧ ਤੋਂ ਵੱਧ () ਵਿਧੀ ਨੂੰ ਕਾਲ ਕਰ ਸਕਦੇ ਹੋ.

Webdriver driver = new FirefoxDriver(); driver.manage().window().maximize();

ਅੱਗੇ ਪੜ੍ਹਨ:

ਦਿਲਚਸਪ ਲੇਖ