cancel
Showing results for 
Search instead for 
Did you mean: 

Maximize web browser window in TestLeft

SOLVED
Highlighted
Frequent Visitor

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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Maximize web browser window in TestLeft

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

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
1 REPLY 1
Community Hero

Re: Maximize web browser window in TestLeft

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

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
New Here?
Join us and watch the welcome video:
Update to TestLeft 2.3
Labels