How to Automate Real Time Scenario Using Java Selenium?

Automate Real-Time Scenario Example Program: How to Automate A Real-Time Scenario Using Java Selenium?

  • Open Website: Link
  • Steps to automate
  • Click on “Self Help” on the right side of the screen.
  • Click on “How to embed flows in my website or application”
  • A tooltip points to the ’embed’ option now. Click on ’embed’.
  • Click on ‘slideshow’.
  • After this, click ‘next’ on a tooltip.
  • Click on close.
  • Finally, this popup comes:
  • Click on close

Ans:

Automate Real-Time Scenario

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class newcodeassignment
{
   public static void main(String[] args) throws InterruptedException {

      WebDriver driver=new FirefoxDriver();
      driver.get("https://whatfix.com/quickolabs.com/#!flows/how-to-import-google-analytics-solution-of-whatfix/8174f470-9df9-11e3-8178-386077c653fe/");;
      driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
      driver.findElement(By.xpath("//a[text()='Self Help']")).click();
      WebElement ele = driver.findElement(By.xpath("//iframe[@class='WFEMES WFEMBT WFEMFV WFEMDV WFEMJM WFEMCT']"));
      driver.switchTo().frame(ele);
      driver.findElement(By.xpath("//a[text()='How to embed flows in my website or application?']")).click();

      driver.switchTo().defaultContent();	
      WebElement ele2 = driver.findElement(By.xpath("//a[text()='embed']"));
      Thread.sleep(3000);
      JavascriptExecutor js = (JavascriptExecutor)driver;
      js.executeScript("arguments[0].click();", ele2);

      Thread.sleep(3000);
      driver.findElement(By.xpath("//a[text()='slideshow']")).click();
      Thread.sleep(4000);
      WebElement ele44 = driver.findElement(By.xpath("//div[@class='WFEMHT']//a[text()='next']"));
      JavascriptExecutor js1 = (JavascriptExecutor)driver;
      js1.executeScript("arguments[0].click();", ele44);

      Thread.sleep(2000);
      driver.findElement(By.xpath("//a[text()='close']")).click();

      WebElement ele55 = driver.findElement(By.xpath("//iframe[@class='WFEMES WFEMKS']"));
      driver.switchTo().frame(ele55);

      driver.findElement(By.xpath("//button[text()='CLOSE']")).click();
   }
}

Avatar for Softwaretestingo Editorial Board

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

2 thoughts on “How to Automate Real Time Scenario Using Java Selenium?”

  1. Hi,
    the link of the site that u provided for testing, is different I think because the elements mentioned in the steps are not present on site.

    Reply
    • Maybe the structure of the site got changed. But thanks for reporting we will check and update the same .

      Reply

Leave a Comment