Selenium coding drill wk#2

Selenium Drill Wk#2 Solution

The week 2 selenium drill question was:

The challenge is to launch Techcanvass website (http://techcanvass.com) and then click “Selenium 3.0 Certification with Java” link under “Selenium Certifications” tab on Home page.

Selenium Drill Wk#2 Solution

If we had to click “Selenium 3.0 Certification with Java” manually, first we would move our mouse to hover on “Selenium Certifications” tab and then click “Selenium 3.0 Certification with Java” link.

Similarly working with Selenium WebDriver, we also have to move our mouse to hover on “Selenium Certifications” tab and then click “Selenium 3.0 Certification with Java” link.

The above operation can be performed by using Action command of Selenium.

Code:

public class Action {

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

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

                                WebDriver driver = new ChromeDriver();

                                driver.manage().window().maximize();

                                WebDriverWait wait = new WebDriverWait(driver,120);

                                driver.get(“http://techcanvass.com/”);

                                wait.until(ExpectedConditions.elementToBeClickable(By.linkText(“Selenium Certifications”)));

                                Actions action = new Actions(driver);

                                action.moveToElement(driver.findElement(By.linkText(“Selenium Certifications”))).build().perform();

                                wait.until(ExpectedConditions.elementToBeClickable(By.linkText(“Selenium 3.0 Certification with Java”)));

                                driver.findElement(By.linkText(“Selenium 3.0 Certification with Java”)).click();

                                Thread.sleep(5000);

                                driver.close();

                }

}

The above code will launch Techcanvass website (http://techcanvass.com) in Chrome browser. Later it would hover on “Selenium Certifications”. This would provide with the list all the Selenium certification courses.  It would later click “Selenium 3.0 Certification with Java” link and close the driver.

If user doesn’t uses Action command and directly clicks “Selenium Certifications” tab to enable the list then it will get redirected to Selenium course page.

Note: We have used wait command to wait until the element which we have to click is clickable.

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