WebElement 接口共计16个------------接口 代表一个HTML元素。通常,所有与页面交互有关的有趣操作都将通过此界面执行。 void clear() void click() WebElement findElement(By by) List<WebElement> findElements(By by) String getAttribute(String name) String getCssValue(String propertyName) Point getLocation() Rectangle getRect() Dimension getSize() String getTagName() String getText() boolean isDisplayed() boolean isEnabled() boolean isSelected() void sendKeys(CharSequence... keysToSend) void submit() 如何调用driver.findElement().XXX ----------------------------------------------------------------------------- WebDriver接口共计13个方法----------接口 用于测试的主接口,代表了一个理想化的网页浏览器。 这个接口中的方法分为三类: 1控制浏览器本身 2 WebElements的选择 3调试帮助 void close() WebElement findElement(By by) List<WebElement> findElements(By by) void get(String url) String getCurrentUrl() String getPageSource() String getTitle() String getWindowHandle() Set<String> getWindowHandles() WebDriver.Options manage() WebDriver.Navigation navigate() void quit() WebDriver.TargetLocator switchTo() 如何调用 driver.XXX ------------------------------------------------------------------------ WebDriver.ImeHandler 接口共计5个方法: 管理输入设备方法的接口。 void activateEngine(String engine) void deactivate() String getActiveEngine() List<String> getAvailableEngines() boolean isActivated() 如何调用 driver.manage().ime().XXX ---------------------------------------------------------------------- WebDriver.Navigation 接口共计5个方法 void back() void forward() void refresh() void to(String url) void to(java.net.URL url) 如何调用driver.navigate().XXX ----------------------------------------------------------------------------- WebDriver.Options 接口共计10个方法 用于管理您在浏览器菜单中执行的操作的界面 void addCookie(Cookie cookie) void deleteAllCookies() void deleteCookie(Cookie cookie) void deleteCookieNamed(String name) Cookie getCookieNamed(String name) Set<Cookie> getCookies() WebDriver.ImeHandler ime() Logs logs() WebDriver.Timeouts timeouts() WebDriver.Window window() 如何调用driver.manage().XXX ----------------------------------------------------------------------------- WebDriver.TargetLocator 接口共计8个方法 用于查找给定的frame框架或窗口window. WebElement activeElement() Alert alert() WebDriver defaultContent() WebDriver frame(int index) WebDriver frame(String nameOrId) WebDriver frame(WebElement frameElement) WebDriver parentFrame() WebDriver window(String nameOrHandle) 如何调用driver.switchTo().XXX ----------------------------------------------------------------------------- WebDriver.Timeouts 接口共计3个方法 用于管理WebDriver实例的超时行为的接口。 WebDriver.Timeouts implicitlyWait(long time, java.util.concurrent.TimeUnit unit) WebDriver.Timeouts pageLoadTimeout(long time, java.util.concurrent.TimeUnit unit) WebDriver.Timeouts setScriptTimeout(long time, java.util.concurrent.TimeUnit unit) 如何调用 driver.manage().timeouts().XXX ----------------------------------------------------------------------------- WebDriver.Window 接口共计6个方法 void fullscreen() Point getPosition() Dimension getSize() void maximize() void setPosition(Point targetPosition) void setSize(Dimension targetSize) driver.manage().window().XXX ----------------------------------------------------------------------------- Select 类共计有11个方法 void deselectAll() void deselectByIndex(int index) void deselectByValue(String value) void deselectByVisibleText(String text) List<WebElement> getAllSelectedOptions() WebElement getFirstSelectedOption() List<WebElement> getOptions() boolean isMultiple() void selectByIndex(int index) void selectByValue(String value) void selectByVisibleText(String text) 调用 Select select = new Select(WebElement); select.XXX ----------------------------------------------------------------------------- Actions 类共计个27方法 实现构建器模式:构建一个CompositeAction,其中包含由方法调用指定的所有操作。 Action build() Actions click() Actions click(WebElement target) Actions clickAndHold() Actions clickAndHold(WebElement target) Actions contextClick() Actions contextClick(WebElement target) Actions doubleClick() Actions doubleClick(WebElement target) Actions dragAndDrop(WebElement source, WebElement target) Actions dragAndDropBy(WebElement source, int xOffset, int yOffset) Actions keyDown(java.lang.CharSequence key) Actions keyDown(WebElement target, java.lang.CharSequence key) Actions keyUp(java.lang.CharSequence key) Actions keyUp(WebElement target, java.lang.CharSequence key) Actions moveByOffset(int xOffset, int yOffset) Actions moveToElement(WebElement target) Actions moveToElement(WebElement target, int xOffset, int yOffset) Actions pause(java.time.Duration duration) Actions pause(long pause) void perform() Actions release() Actions release(WebElement target) Actions sendKeys(java.lang.CharSequence... keys) Actions sendKeys(WebElement target, java.lang.CharSequence... keys) Actions tick(Action action) Actions tick(Interaction... actions)