Maitiro ekudzora saizi yeBrowser Window muWebDriver

Maitiro ekudzora saiti yebrowser neSelenium WebDriver? Pano, isu tinotarisa nzira nhatu dzakasiyana dzatinogona kudzora bhurawuza hwindo muWebDriver.

Chero nguva iyo WebDriver painotanga browser, inotangisa iine default maseturu. Dzimwe nguva zvinotarisirwa kudzikamisa hwindo rebrowser, kunyanya patinenge tichiyedza inoteerera mawebhusaiti nekuti isu tinofanirwa kutarisa kuti tione kuti zvinhu zvakasiyana zviri papeji zvinopa sei patinoshandura hwindo rebrowser.

Webdriver ine nzira dziri nyore uye nzira dzakasiyana dzinogona kutibvumira kudzora hwindo rebrowser.

Resize Browser Window muWebDriver

Java uchishandisa Dimension

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);
} }

Java uchishandisa Chrome sarudzo

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/');
} }

Kana iwe uchida kuwedzera iro bhurawuza hwindo kusvika pakakwirira upamhi uye kukwirira kwechidzitiro, unogona kungodaidza iyo maximize () nzira



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

Kuenderera mberi nekuverenga: