Wednesday, February 12, 2020

Localization Automation (Developed Automation script via VPN)

If site is only accessible from VPN then needs to connection

There are two ways of automating such scenarios :


  1.   ADDING CHROME EXTENSION AT RUN TIME USING SELENIUM :
                 a.  Add the chrome plugin in chrome browser
                 b.  Right click on Plugin >> manage extension
                 c.   On redirection copy the URL







                d. First, need to download the .crx file of the extension. 
                e.  Go to  https://crxextractor.com/ then enter the link of the chrome extension in the download box then click on Get .CRX button. 
             


               g.    GIVE THE PATH OF THE CRX FILE TO THE ADDEXTENSIONS() METHOD


package Test;
 
import java.io.File;
import java.util.concurrent.TimeUnit;
 
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
 
public class AddChromeExtension {
 
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
ChromeOptions option = new ChromeOptions();
option.addExtensions(new File("C:\\Users\\sac\\Downloads\\extension_3_5_0_0.crx"));
WebDriver  driver  = new ChromeDriver(option);
driver.get("https://www.inviul.com/");
     
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
     driver.manage().window().maximize();
     
     System.out.println(driver.getTitle());
 
}
 
}

    f. When run Selenium script , Browsers have extension :



2.    Create new profile in firefox browser :

            a.   Open firefox browser and add  "about:profiles" in url 
            b.  Create a new profile   



                    c. 
  1. If Firefox is open, close Firefox: Click the Firefox menu Fx57Menu and select Exit.
  2. Press Windows Key +R on the keyboard. A Run dialog will open.
  3. In the Run dialog box, type in:
    firefox.exe -P
    You can use -P-p or -ProfileManager (any of them should work).
  4. Click OK. The Firefox Profile Manager (Choose User Profile) window should open.
// import the package
import java.io.File;
      import java.util.concurrent.TimeUnit;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class FirefoxProfile {
  public static void main(String[] args) {
 ProfilesIni profile = new ProfilesIni();
 FirefoxProfile myprofile = profile.getProfile("xyzProfile");
// Initialize Firefox driver
 WebDriver driver = new FirefoxDriver(myprofile);
//Maximize browser window
 driver.manage().window().maximize();
//Go to URL which you want to navigate
 driver.get("http://www.google.com");
//Set  timeout  for 5 seconds so that the page may load properly within that time
 driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//close firefox browser
 driver.close();
}

}



No comments:

Post a Comment