简体   繁体   中英

How to maximize browser using Sahi with java

I'm using Sahi Java Driver. My Java code with Sahi is running well. When tests are being executed the browser (in my case Firefox) is not maximized. The snippet of my Sahi Java code as below:

String browserType = "firefox";
Browser browser = new Browser(browserType);
browser.open();

How can I maximize the browser in Sahi with Java?

If you are using Sahi Pro, you have a browserAction API which takes in maximize as a parameter. This will maximize your browser. It also takes other parameters such as focus, minimize, refresh etc. You can check that out. So your code can be something like this:

browser.windowAction('maximize') //please check the syntax, copy paste might go wrong

The following line of Sahi Java code work fine. Add the following line of code after browser.open() ;

browser.focusWindow();

I think it should be like,

-Make a Java Script code for full screen

function maximize() {
window.moveTo(0, 0);
window.resizeTo(screen.width, screen.height);
}
maximize();

-Run this script before start the test browser.execute("ScriptToRun")

thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM