Over a period of time, Selenium has become the most widely used test automation tool in the world and there is a huge demand for selenium experts across the world. In order to meet the ever increasing demand for selenium experts, many Selenium tutorials have come up. The selenium technology will be taught in detail in these tutorials.
When you use Selenium, though rarely, you may come across several issues and you should be prepared to overcome these hurdles. Here in this chapter of our Selenium Tutorial, we will discuss a few such trivial but important topics that would help to troubleshoot such recurring problems.
Selenium Scripting and Troubleshoot Scenarios
There are certain actions that become the inherent part of the test scripts when a test scenario is getting automated. These actions can be any of the following.
- Clicking a button, hyperlink etc
- Typing in a text box
- Scrolling horizontally or vertically to bring an object into view
- Or some other similar actions
executeScript ( String script, args)
executeAsyncScript (String script, args )
- Scripts: – The scripts to be executed
- Argument: – Parameters required by the scripts for execution (if any)
Clicking a Web Element
// Locating the web element using id
WebElement element = driver.findElement(By.id(“id of the webelement”));
// Clicking the web element
Typing a Text Box
// Typing the test data into Textbox
js.executeScript(“document.getElementById(‘id of the element’).value=’test data’;”);
Scrolling down until the web element is in the view