Forum Discussion

kdle's avatar
kdle
Frequent Visitor
6 years ago

Maximize web browser window in TestLeft

Pls help. I'm new to TestLeft and I'm looking for a method in C# to maximize/assert a web browser window for the When and Then steps in the example below:

 

 

[Given(@"I have navigated to the google website")]
public void GivenIHaveNavigatedToTheGoogleWebsite()
{
IDriver driver = new SmartBear.TestLeft.LocalDriver();
IWebBrowser browser = driver.Applications.RunBrowser(BrowserType.Chrome, "https://google.com");

}

[When(@"I maximize the window")]
public void WhenIMaximizeTheWindow()
{
//driver.Applications.Browsers.;
}

[Then(@"the window should be maximized")]
public void ThenTheWindowShouldBeMaximized()
{
ScenarioContext.Current.Pending();
}

  • Hi,

     

    ITopLevelWindow of desktop application provides the .Maximize() method.

    The call may be like this:

    ITopLevelWindow browserWindow = driver.Find<IWebBrowser>(new WebBrowserPattern(){ 
    	ObjectIdentifier = "firefox" 
    }).Find<ITopLevelWindow>(new WebBrowserUIPattern(){ 
    	ObjectType = "BrowserWindow", 
    	ObjectIdentifier = 0 
    });
    
    browserWindow.Maximize();

     

    Also, the same can be achieved from the Page object:

    IWebPage page = driver.Find<IWebBrowser>(new WebBrowserPattern(){ 
    	ObjectIdentifier = "firefox" 
    }).Find<IWebPage>(new WebPagePattern(){ 
    	URL = "http://somesite.com/*" 
    });
    
    page.CallMethod("maximize");

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    ITopLevelWindow of desktop application provides the .Maximize() method.

    The call may be like this:

    ITopLevelWindow browserWindow = driver.Find<IWebBrowser>(new WebBrowserPattern(){ 
    	ObjectIdentifier = "firefox" 
    }).Find<ITopLevelWindow>(new WebBrowserUIPattern(){ 
    	ObjectType = "BrowserWindow", 
    	ObjectIdentifier = 0 
    });
    
    browserWindow.Maximize();

     

    Also, the same can be achieved from the Page object:

    IWebPage page = driver.Find<IWebBrowser>(new WebBrowserPattern(){ 
    	ObjectIdentifier = "firefox" 
    }).Find<IWebPage>(new WebPagePattern(){ 
    	URL = "http://somesite.com/*" 
    });
    
    page.CallMethod("maximize");