How to connect extension (dotvpn ) after adding extension in selenium webdriver.

please find the selenium webdriver  using java

package com.demo;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Latestone {
private static final Object Disconnected = null;
public static WebDriver driver;

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

String driverPath = “E:/Test/chromedriver.exe”;

System.setProperty(“webdriver.chrome.driver”, driverPath);

setup();
}
public static void setup() throws Exception {

String pathToExtension = “C://Users//sandeep.pustakala//AppData//Local//Google//Chrome//User Data//Default//Extensions//kejbdjndbnbjgmefkgdddjlbokphdefk//17.285.0_0”;
ChromeOptions options = new ChromeOptions();
options.addArguments(“-load-extension=” + pathToExtension);
driver = new ChromeDriver(options);

//***WEB PAGE TEST STARTED***//

driver.get(“https://chrome.google.com/webstore/search/dotvpn?hl=en-US”);
Thread.sleep(5000);
driver.findElement(By.xpath(“/html/body/div[6]/div[4]/div[2]/div[1]/div/div[1]/div[2]/div[1]/a/div[3]/div[2]/div[1]/div/div/div”)).click();
Thread.sleep(10000);
Robot r = new Robot();
r.keyPress(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_TAB);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
Thread.sleep(10000);
System.out.println(“click on extension”);

driver.get(“https://www.webpagetest.org”);

driver.findElement(By.partialLinkText(“Login”)).click();
driver.findElement(By.name(“username”)).sendKeys(“qapalred”);
driver.findElement(By.name(“password”)).sendKeys(“qapalred”);
driver.findElement(By.name(“submit”)).click();
driver.findElement(By.id(“url”)).sendKeys(“www.uat.latestone.com”);
driver.findElement(By.id(“location”)).sendKeys(“Mumbai,India-EC2(Chrome)”);
Select dropdown = new Select(driver.findElement(By.id(“browser”)));
dropdown.selectByIndex(0);
System.out.println(“webpagetesting”);
driver.findElement(By.id(“advanced_settings”)).click();
System.out.println(“advanced_settings”);
Select dropdown1 = new Select(driver.findElement(By.id(“connection”)));
dropdown1.selectByIndex(0);
driver.findElement(By.id(“viewBoth”)).click();
Thread.sleep(3000);
driver.findElement(By.name(“video”)).click();
System.out.println(“checkbox clicked”);
driver.findElement(By.name(“private”)).click();
driver.findElement(By.partialLinkText(“Chrome”)).click();
driver.findElement(By.name(“timeline”)).click();
driver.findElement(By.name(“submit”)).click();
System.out.println(“submit completed==”);
Thread.sleep(180000);
//**WEB PAGE TEST SUBMITTED**//
driver.manage().timeouts().implicitlyWait(5, TimeUnit.MINUTES);
//WebDriverWait wait = new WebDriverWait(driver,300 );
//wait.until(ExpectedConditions.titleContains(“Performance Results (Median Run)”));
driver.findElement(By.partialLinkText(“Summary”)).click();
System.out.println(“before CLICK ON WATERFALL”);
driver.findElement(By.xpath(“//*[@id=’run1_step1′]/td[2]/a/img”)).click();
driver.findElement(By.partialLinkText(“Summary”)).click();
driver.findElement(By.xpath(“//*[@id=’run2_step1′]/td[2]/a/img”)).click();
driver.findElement(By.partialLinkText(“Summary”)).click();
driver.findElement(By.xpath(“//*[@id=’run3_step1′]/td[2]/a/img”)).click();
System.out.println(“THE END”);

}

}

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.