Selenium WebDriver commands grouped by Browser Commands, WebElement Commands, and Navigation Commands.
Here’s a more comprehensive list of all major Selenium WebDriver commands grouped by Browser Commands, WebElement Commands, and Navigation Commands.
This includes both commonly used and less frequent ones.
✅ 1. Browser Commands
(For browser-level actions)
Command | Description |
---|---|
driver.get("url") |
Opens a webpage. |
driver.getTitle() |
Gets the page title. |
driver.getCurrentUrl() |
Gets current URL. |
driver.getPageSource() |
Gets full HTML source. |
driver.getWindowHandle() |
Gets window handle of current window. |
driver.getWindowHandles() |
Gets handles of all open windows/tabs. |
driver.close() |
Closes current window. |
driver.quit() |
Quits all windows and ends session. |
driver.manage().window().maximize() |
Maximizes the window. |
driver.manage().window().minimize() |
Minimizes the window. |
driver.manage().window().fullscreen() |
Fullscreen the window. |
driver.manage().window().setSize(new Dimension(w, h)) |
Sets custom window size. |
driver.manage().window().getSize() |
Gets current window size. |
driver.manage().window().setPosition(new Point(x, y)) |
Sets window position. |
driver.manage().window().getPosition() |
Gets window position. |
driver.manage().timeouts().implicitlyWait() |
Sets implicit wait timeout. |
driver.manage().timeouts().pageLoadTimeout() |
Sets page load timeout. |
driver.manage().timeouts().setScriptTimeout() |
Sets script execution timeout. |
driver.switchTo().frame() |
Switch to iframe. |
driver.switchTo().defaultContent() |
Switch to main content from iframe. |
driver.switchTo().alert() |
Switch to alert. |
driver.switchTo().window("name or handle") |
Switch to window/tab by handle. |
✅ 2. WebElement Commands
(Used after locating elements)
Command | Description |
---|---|
element.click() |
Clicks the element. |
element.sendKeys("text") |
Types into the element. |
element.clear() |
Clears text field. |
element.getText() |
Gets visible text. |
element.getTagName() |
Gets tag name (div , input , etc.). |
element.getAttribute("name") |
Gets attribute value. |
element.getCssValue("property") |
Gets CSS property value. |
element.isDisplayed() |
Checks if visible. |
element.isEnabled() |
Checks if enabled. |
element.isSelected() |
Checks if checkbox/radio is selected. |
element.submit() |
Submits a form. |
element.findElement(By...) |
Finds nested element. |
element.findElements(By...) |
Finds nested elements. |
element.getLocation() |
Gets element position (x,y). |
element.getSize() |
Gets element height and width. |
element.getRect() |
Gets location + size in one object. |
✅ 3. Navigation Commands
(Used to control browser history and page reload)
Command | Description |
---|---|
driver.navigate().to("url") |
Navigate to URL (same as get ). |
driver.navigate().back() |
Go back to previous page. |
driver.navigate().forward() |
Go forward. |
driver.navigate().refresh() |
Reload current page. |
Comments
Post a Comment