Selenium commands




The `CaptureBrowser` command is designed to take a screenshot of the content currently displayed in the open browser window. This allows you to capture exactly what is being shown in the browser, excluding any external desktop or application interfaces, focusing solely on the web content itself.


The `Clear` command is used to remove all text from the text field that is currently focused. This action empties the text field, making it ready for new input.


The `ClickId` command executes a click action on a web page element that is identified by its unique ID. For instance, using `ClickId “js-lang-list-button”` would click on the element with the ID “js-lang-list-button”, such as a language list button on Wikipedia. This command is useful for interacting with specific elements on a web page directly by their ID, ensuring precise control over which element is targeted for the click action.


The `ClickText` command is designed to initiate a click action on a web page element that contains specific text. This command searches for elements like Table cells, links (anchor tags `a`), and potentially other tags containing the specified text. For accurate implementation, you would need to inspect the code or documentation to determine which tags are supported by this command. This functionality allows for interaction with web elements based on their visible text content, providing a more control and intuitive way to navigate.


The `ClickXpath` command is used to click on a web element identified by its XPath, which is a pathway or a query language for selecting nodes from an XML document, and by extension, used in web pages. To use this command, you can copy the XPath of the desired element directly from the web browser’s developer tools. When incorporating the XPath in your command, remember to escape any quotation marks within the XPath string by adding a backslash (`\`) before them. For instance, if the original XPath contains quotation marks, you should replace each `”` with `\”` to ensure the command is interpreted correctly. This adjustment is necessary for the command to process the XPath string accurately.


The `CloseBrowser` command is used to close the currently open web browser window. This command effectively terminates the browser session, closing any open tabs or windows associated with the browser instance.


The `FullscreenBrowser` command is used to expand the currently open web browser window to full screen mode. This action maximizes the browser, covering the entire screen and providing an immersive viewing experience without the distraction of other desktop or system elements.


The `GetAttribute` command retrieves the value of a specified attribute from the currently focused web element or widget. For example, by using `GetAttribute “name”`, it fetches the value of the “name” attribute of the element in focus. The result of this operation is then stored in a parameter named “Response”.


The `GetSelectedText` command is designed to capture the currently selected option’s text from a dropdown list. The text of the selected item is then stored in a parameter named “Response”. This functionality is particularly useful for verifying that the correct option has been selected in a dropdown menu, a common requirement in web testing and automation tasks.


The `GetTagName` command is used to retrieve the tag name of the web element currently in focus. The name of the tag is then stored in a parameter named “Response”. This functionality is useful for identifying the type of element you’re interacting with on a web page, aiding in web development and testing processes by providing insight into the structure and hierarchy of the web document.


The GetURL command is used to retrieve the current URL displayed in the web browser. This command captures the web address of the page you are currently viewing and can store it in a variable or output it directly for further use in the script.


The `GetValue` command is designed to retrieve the current value or text from the web element that is currently focused, such as a text field, dropdown menu, or list. The retrieved value is then stored in a parameter named “Response”. This functionality is useful for extracting the input or selection made by a user or pre-defined in the element, facilitating validation, testing, or further processing of web forms and interactive elements.


The `GetXpathValue` command is used to fetch the value or text content of a web element specified by its XPath. Similar to the formatting guidelines mentioned for the `ClickXpath` command, when using `GetXpathValue`, ensure that any quotation marks within the XPath expression are properly escaped with a backslash (`\`). This command effectively allows you to extract and utilize the content of specific elements on a web page, making it particularly useful for web automation and testing scenarios where retrieving dynamic information is necessary.


The `MaximizeBrowser` command enlarges the browser window to fill the entire screen while still keeping the window bar (title bar and controls) visible. Unlike full-screen mode, which hides the window bar for a completely immersive view, maximizing the browser ensures that you have quick access to the window controls, such as minimize, maximize, and close buttons, as well as the ability to see the title of the current webpage. This command is useful for maximizing the viewing area without losing the functionality provided by the window bar.


The `OpenBrowser` command initiates a new web browser session using a web driver. This command is particularly useful in automated testing and web scraping, as it allows you to programmatically launch a browser instance for navigating websites, executing tests, or performing tasks. The web driver acts as an intermediary between your script and the browser, enabling control over the browser’s actions, such as navigating to URLs, clicking links, filling out forms, and more.


The `SelectIndex` command selects an element based on its index position within a list or dropdown menu that is currently in focus. It’s important to note that indexing starts at 0, meaning the first element is indexed as 0, the second as 1, and so on. For example, using `SelectIndex “1”` would select the second element in a dropdown menu. This command is especially useful for interacting with lists or dropdowns when you know the position of the item you want to select but might not know its value or text.


The `SelectText` command is used to select an item from a dropdown menu or list based on the item’s visible text. For instance, executing `SelectText “Swimming”` would choose the item labeled “Swimming” from the currently focused dropdown or list. This command is particularly useful for web forms and applications where selections need to be made from a list of textual options, allowing for precise control over the selection process based on the text content.


The `SelectValue` command targets and selects an item within a dropdown menu or list based on the item’s value attribute in the HTML, not its visible text. For example, if you use `SelectValue “Swimming”`, the command looks for an item in the dropdown or list that has a value attribute set to “Swimming” and selects it. This is particularly useful when interacting with web elements where the value attribute holds the key information for selection, rather than the text the user sees. It ensures that the correct item is selected based on its underlying value, which is especially important in web forms where the displayed text might not match the value used in the form’s backend processing.


The `WaitId` command is used to pause script execution until a web element with a specific ID becomes available in the page. For example, using `WaitId “activities”` instructs the script to wait for an element with the ID “activities” to load. It’s important to note that an element’s presence in the DOM does not necessarily mean it is ready to interact with, such as receiving input or being clickable.


The `WaitName` command pauses script execution until a web element with a specific `name` attribute is loaded and available in the page. Similar to `WaitId`, but targeting the `name` attribute instead, this command ensures that the script only proceeds once an element with the designated name becomes interactable. For instance, `WaitName “email”` would hold the script until an element with the name attribute set to “email” is ready.


The `WaitText` command is designed to pause the execution of a script until a web element containing specific text becomes available on the page. This command operates similarly to `WaitId`, but it focuses on the visible text within elements rather than their `id` or `name` attributes. Given the variability and dynamic nature of web content, using `WaitText` can be challenging because the exact match of the text must be identified, and text content is more prone to changes compared to element IDs or names. This command is useful for ensuring that elements with specific textual content are fully loaded and ready for interaction, which is crucial for tasks that depend on the presence of certain text on a web page.


The `WriteText` command is used to input text into the text field that is currently in focus. This allows you to programmatically simulate typing into a form field, search box, or any other text input area on a webpage. This command is particularly useful for automating data entry, form submissions, or any scenario where textual input is required.



The `Set` command is used to create and assign a value to a parameter within your script. For instance, by executing `Set {location} “500 500”`, you define a parameter named `location` and assign it the value “500 500”. This parameter can then be utilized in subsequent commands, such as `Click {location}`, to perform actions based on the parameter’s value. This functionality is crucial for creating dynamic scripts where specific values need to be reused or updated throughout the execution process.


The `Find` method searches for an image on the screen and returns two important pieces of information: `MatchLocation` and `MatchCount`. `MatchLocation` gives the coordinates (x, y) of where the image was found, and `MatchCount` tells you how many times the image was spotted. These parameters can be very useful for further steps in your script. For example, you can use `Click {MatchLocation}` to click on the exact location where the image was detected. This ability is especially helpful for automating tasks that involve interacting with specific images or elements on the screen.


You can set up conditions using expressions like `{Param}=”value”` or `{Param}<“2″` and use them in `If` and `IfNot` statements. This way, you can make your script take different actions depending on whether these conditions are true or not. For example, you can tell the script to do something if a parameter equals a certain value or if it’s less than a number.