Selenium WebDriver命令
最常用的命令
下表列出了webdriver的最常用的命令以及它的语法,这将有助于我们开发webdriver脚本。
| Commmand | 描述 |
|---|---|
| driver.get("URL") | 导航到应用程序 |
| element.sendKeys("inputtext") | 输入一些文本输入框 |
| element.clear() | 从输入框清空内容 |
| select.deselectAll() | 这将取消选择页面上的第一个选择所有选项: |
| select.selectByVisibleText("some text") | select the OPTION with the input specified by the user. |
| driver.switchTo().window("windowName") | Moving the focus from one window to another |
| driver.switchTo().frame("frameName") | swing from frame to frame |
| driver.switchTo().alert() | Helps in handling alerts |
| driver.navigate().to("URL") | Navigate to the URL |
| driver.navigate().forward() | To Navigate forward |
| driver.navigate().back() | To Navigate back |
| driver.close() | Closes the current Browser associated with the driver |
| driver.quit() | Quits the driver and closes all the associated window of that driver. |
| driver.refresh() | Refreshes the current page. |
浙公网安备 33010602011771号