Selenium Drill Week 1

Selenium Drill Wk#1 Solution

The question for Week 1 selenium drill was:

Write Selenium script to launch Techcanvass website ( and then click on a hidden element with id=hdnCourseNameP.

Selenium Drill Wk#1 Solution

Selenium is designed to interact with the web application as a user. So if the element is not visible on UI then the user cannot click it.

Similarly even Selenium cannot click or perform any action on an element which is not visible on UI since Selenium is a Web Automation tool.

But even if user wants to click a hidden element, then the operation can be performed by using Java Script programming language. User can use JavaScriptExecutor interface to execute JavaScript through Selenium Webdriver.


public class Hidden {

                public static void main(String[] args) throws InterruptedException {

                                System.setProperty(“”, “<Path>”);

                                WebDriver driver = new ChromeDriver();




                                JavascriptExecutor js = ((JavascriptExecutor)driver);

                                WebElement hidden = driver.findElement(“hdnCourseNameP”));

                                js.executeScript(“arguments[0].click();”, hidden);





The above code will launch Techcanvass website ( and then click “hdnCourseNameP” element using JavascriptExecutor interface.

But if user doesn’t use JavascriptExecutor interface and directly tries to click “hdnCourseNameP” element then it will get an exception error “org.openqa.selenium.ElementNotVisibleException: element not visible”.

Wait for the next week’s coding challenge.

About Techcanvass

Techcanvass offers IT certification courses for professionals. We are an IIBA endorsed education provider (EEP), iSQI ATP (for Certified Agile Business Analyst Training) as well as Agile Testing alliance partner for CP-SAT certification training in Selenium.

Our Selenium 3.0 Training programs along with DevOps courses are designed for Manual testing professionals with basics of Java and Python covered.

Selenium 3.0 Training in Mumbai

This is the weekly Selenium drill with solution.

Selenium 3.0 Training with Python

python selenium training

Selenium Certification Training (CP-SAT)

Selenium Certification Course