• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Test Case Examples
  • Interview Questions
  • Interview Questions Asked
  • Java
  • Selenium
  • Manual Testing
  • SQL Tutorial For Beginners
  • Difference
  • Tools
  • Contact Us
  • Search
SoftwareTestingo » Selenium » Selenium Programs » How to Automate Real Time Scenario Using Java Selenium?

How to Automate Real Time Scenario Using Java Selenium?

Last Updated on: November 5, 2018 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • Automate Real-Time Scenario

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();
   }
}

    Filed Under: Selenium Programs

    Reader Interactions

    Comments

    1. Avatar for ShubhamShubham says

      February 10, 2022 at 10:57 AM

      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
      • Avatar for Softwaretestingo Editorial BoardSoftwaretestingo Editorial Board says

        February 10, 2022 at 3:03 PM

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

        Reply

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2023 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers