Me pehea te whakarereke i te Matapihi Tirohanga i roto i te WebDriver

Me pehea te whakarereke i te matapihi tirotiro ki a Selenium WebDriver? I konei, ka tirohia e toru nga huarahi ka taea te whakarereke i te matapihi tirotiro i te WebDriver.

I nga wa katoa ka tiimata te WebDriver ki te tirotiro, ka tiimata me nga tautuhinga taunoa. I etahi wa ka hiahiatia kia whakarereke te rahi o te matapihi tirotiro, ina koa ka whakamatautauria e maatau nga papanga paetukutuku whakautu na te mea me tirotiro taatau kia pehea te rereketanga o nga waahanga o te whaarangi ka huri ana i te rahi o te matapihi tirotiro.

Kei a Webdriver nga tikanga ngawari me nga huarahi rereke e taea ai te huri i te rahi o te matapihi tirotiro.

Huria te rahi o te Matapihi Tirohanga i roto i te WebDriver

Java te whakamahi i te Ahu

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 te whakamahi i nga whiringa Chrome

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

Ki te hiahia koe ki te whakanui i te matapihi tirotiro ki te whanui me te teitei o te mata, ka taea te karanga i te tikanga whakanui ()



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

Panui atu: