Browsers Setting

package WebdriverStart;

import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

public class Firefoxprofiler {

public static void main(String[] args) {
//###################For selenium console data
// System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"null");//no file will be generated at console
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"G:\\Prac_data\\testlog.txt");//no file will be generated at console
// #################binary file(FirefoxOptions class)

FirefoxOptions options= new FirefoxOptions();
options.setBinary("path of the firefox exe");//if selenium doesnt find the firefox.exe

//##############PageLoadStrategy#################(FirefoxOptions class)
options.setPageLoadStrategy(PageLoadStrategy.NONE);// if page take lot of time to load ,then we use this to write whenever we find Object/property
//options.setPageLoadStrategy(PageLoadStrategy.EAGER);//it writes little faster
//options.setPageLoadStrategy(PageLoadStrategy.NORMAL);//it write as normal

ProfilesIni allProofiles= new ProfilesIni();//All profile in PC
//########Notifications
FirefoxProfile prof= allProofiles.getProfile("Mod11");
prof.setPreference("dom.webnotifications.enabled", false);//to stop the notifications
//Certificates- Htts://192.143.34.33(Error --> add exception to website )
prof.setAcceptUntrustedCertificates(true);
prof.setAssumeUntrustedCertificateIssuer(false);
//#### Connecting proxy server to do operations /everyhting goes through that server
prof.setPreference("network.proxy.type", 1);
prof.setPreference("network.proxy.socks", "10.123.34.22");
prof.setPreference("network.proxy.socks_port", 1235);
options.setProfile(prof);
//System.out.println("hello");
WebDriver driver= new FirefoxDriver(options);
driver.get("https://www.whizdomtraining.com/user/home/videos_part/Selenium/Module-12");

//#########Profilling####################


}
}


---------------------------------------------------------------------------------------------------------
package WebdriverStart;

import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;


public class ChromeDriverSettings {

public static void main (String[]args){
// Notifications
ChromeOptions options= new ChromeOptions();
//diasble the notifications
options.addArguments("--disable-notifications");
//diasble the infobars
options.addArguments("disable-infobars");
//old versions of selenium will not maxmize then we use this
    options.addArguments("--start-maximized");
    //proxy server
    //options.addArguments("--proxy-server=http://10.222.333.22");
    //Profilling
    options.addArguments("user-data-dir=c:C:\\Users\\sudee\\AppData\\Local\\Google\\Chrome\\User Data");//user 1 profile
    options.addArguments("user-data-dir=c:C:\\Users\\sudee\\AppData\\Local\\Google\\Chrome\\User Data1");//user 2
//pageLoadStratergy
    options.setPageLoadStrategy(PageLoadStrategy.EAGER);
    //binary path is not found
    options.setBinary("path");
// below for console logs
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "G:\\Prac_data\\testlog.log");//it write to outputfile and disapper from console
System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true"); //it wil disapper from console
WebDriver driver= new ChromeDriver(options);
driver.get("https://www.whizdomtraining.com/user/home/videos_part/Selenium/Module-12");
}
}
-----------------------------------------------------------------------------------------------------------
package WebdriverStart;

import org.openqa.selenium.By;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

public class EdgeBrowser {

public static void main(String[] args) {
//No notoification 
//no profiling im edge
// in edge setting we get manage the Notification 
//Edge browser version in important.
//proxy can be set using browser settings
//it  the object find it will write to it or perform action on the object
EdgeOptions options= new EdgeOptions();
options.setPageLoadStrategy("Eager");
EdgeDriver driver = new EdgeDriver(options);
driver.get("http://192.163.17:2083/");
//Manage cerificate 
driver.findElement(By.id("moreInformationDropdownSpan")).click();
driver.findElement(By.id("invalidcert_continue")).click();
}

}
------------------------------------------------------------------------------------------------------------------
package WebdriverStart;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

public class IEBrowsersSettings {

public static void main(String[] args) {
//console logs control
System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGLEVEL_PROPERTY, "INFO");
System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGLEVEL_PROPERTY, "FATAL");
System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGLEVEL_PROPERTY, "ERROR");
System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY, "D://logs//test.log");
InternetExplorerOptions options= new InternetExplorerOptions();
//options.
// driver = new InternetBrowser();

}

}

Comments

Popular posts from this blog

ACCELQ

XML API