问题描述
我的一个朋友问我一个问题,以下是最大化窗口的代码.
One of my friend has asked me a question that below is the code to maximize the window.
driver.manage().window().maximize();
这里manage()
是什么?
据我所知,manage()
是抽象方法.
As per my knowledge manage()
is the abstract method.
请任何人解释以下行的含义,以及如何通过编写以下代码来使用maximize()
方法:
Please anyone explain the meaning of below line, how we are able to use maximize()
method by writing below code:
driver.manage().window().maximize();
预先感谢!
推荐答案
-
基于您的问题驱动程序的是一个具体类的实例,该类实现了WebDriver接口.
Based on your question- driver is an instance of concrete class which implements WebDriver interface.
manage()方法返回称为 WebDriver.Options
manage() method returns an "Option interface" referred to as WebDriver.Options
当您键入 driver.manage()->时,会提供访问方法的列表.
When you type driver.manage(). -> gives you list of methods to access.
Ex.您可以调用方法window()-> driver.manage().window().这将进一步返回用于管理窗口的界面,称为 WebDriver.Window 用于管理当前窗口的界面.
Ex. you can call a method window()->driver.manage().window().This would further return the interface for managing window referred to as WebDriver.Window interface for managing current window.
WebDriver.Window 界面具有一种称为 maximize()的方法.可以使用以下代码进行调用: driver.manage().window().maximize().如果尚未最大化,这将最大化当前窗口.
WebDriver.Window interface has a method called maximize().It can be called using following code: driver.manage().window().maximize(). This would maximize current window if not already maximized.
希望细节对您有所帮助.继续学习.
Hope the details were helpful.Keep learning.
这篇关于在Selenium Webdriver中,什么是manage()[driver.manage()]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!