Skip to content

Instantly share code, notes, and snippets.

@paulbrodner
Forked from stackedsax/selenium2test.java
Last active August 29, 2015 14:06
Show Gist options
  • Save paulbrodner/49276623e44a88fd4dab to your computer and use it in GitHub Desktop.
Save paulbrodner/49276623e44a88fd4dab to your computer and use it in GitHub Desktop.

Revisions

  1. @stackedsax stackedsax renamed this gist Apr 2, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @stackedsax stackedsax created this gist Apr 2, 2012.
    180 changes: 180 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,180 @@
    package com.yahoo.media.mediaqa.selenium2test;


    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.android.AndroidDriver;
    import org.openqa.selenium.firefox.*;
    import org.openqa.selenium.firefox.internal.ProfilesIni;

    import java.io.File;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;

    import org.testng.Assert;
    import org.testng.annotations.*;

    public class selenium2test {

    /**
    * @param args
    */
    @Test
    public static void main(String[] args) {

    //System.setProperty("webdriver.firefox.profile", "Firefox8");
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    FirefoxProfile profile = new FirefoxProfile();
    try {
    profile.addExtension(new File("/Users/xxxx/Downloads/yslow-3.1.0-fx.xpi"));
    profile.addExtension(new File("/Users/xxxx/Downloads/firebug-1.10.0a6.xpi"));
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }

    profile.setPreference("accelerometer.enabled", false);
    profile.setPreference("accessibility.typeaheadfind.enablesound", false);
    profile.setPreference("accessibility.typeaheadfind.flashBar", 0);
    profile.setPreference("alerts.totalOpenTime", 1);
    profile.setPreference("app.update.lastUpdateTime.addon-background-update-timer", 1331590762);
    profile.setPreference("app.update.lastUpdateTime.background-update-timer", 1331590642);
    profile.setPreference("app.update.lastUpdateTime.blocklist-background-update-timer", 1331590882);
    profile.setPreference("app.update.lastUpdateTime.microsummary-generator-update-timer", 1317343851);
    profile.setPreference("app.update.lastUpdateTime.places-maintenance-timer", 1317343255);
    profile.setPreference("app.update.lastUpdateTime.search-engine-update-timer", 1331590522);
    profile.setPreference("browser.bookmarks.max_backups", 0);
    profile.setPreference("browser.bookmarks.restore_default_bookmarks", false);
    profile.setPreference("browser.cache.disk.capacity", 1048576);
    profile.setPreference("browser.cache.disk.smart_size.first_run", false);
    profile.setPreference("browser.cache.disk.smart_size_cached_value", 256000);
    profile.setPreference("browser.history_expire_days.mirror", 180);
    profile.setPreference("browser.migration.version", 5);
    profile.setPreference("browser.offline-apps.notify", false);
    profile.setPreference("browser.places.smartBookmarksVersion", 2);
    profile.setPreference("browser.preferences.advanced.selectedTabIndex", 2);
    profile.setPreference("browser.privatebrowsing.autostart", true);
    profile.setPreference("browser.rights.3.shown", true);
    profile.setPreference("browser.search.suggest.enabled", false);
    profile.setPreference("browser.sessionhistory.max_entries", 5);
    profile.setPreference("browser.sessionstore.max_tabs_undo", 0);
    profile.setPreference("browser.sessionstore.max_windows_undo", 0);
    profile.setPreference("browser.urlbar.autocomplete.enabled", false);
    profile.setPreference("browser.urlbar.maxRichResults", 1);
    profile.setPreference("content.interrupt.parsing", false);
    profile.setPreference("dom.ipc.plugins.enabled.npctrl.dll", false);
    profile.setPreference("dom.ipc.plugins.enabled.npqtplugin.dll", false);
    profile.setPreference("dom.ipc.plugins.enabled.npswf32.dll", false);
    profile.setPreference("dom.ipc.plugins.enabled.nptest.dll", false);
    profile.setPreference("extensions.PageSpeed.autorun", true);
    profile.setPreference("extensions.PageSpeed.beacon.minimal.autorun", true);
    profile.setPreference("extensions.PageSpeed.beacon.minimal.url", "http://util1.qe.media.pool.corp.sp2.yahoo.com/newmanthan/pagespeed.php?wfid=101");
    profile.setPreference("extensions.PageSpeed.optimized_file_base_dir", "C:\\DOCUME~1\\qa-user\\LOCALS~1\\Temp");
    profile.setPreference("extensions.acr.firstrun", false);
    profile.setPreference("extensions.firebug.addonBarOpened", true);
    profile.setPreference("extensions.firebug.allPagesActivation", "on");
    profile.setPreference("extensions.firebug.commandEditor", true);
    profile.setPreference("extensions.firebug.commandLineShowCompleterPopup", false);
    profile.setPreference("extensions.firebug.console.enableSites", true);
    profile.setPreference("extensions.firebug.consoleFilterTypes", "info");
    profile.setPreference("extensions.firebug.currentVersion", "1.9.1");
    profile.setPreference("extensions.firebug.defaultPanelName", "YSlow");
    profile.setPreference("extensions.firebug.net.enableSites", true);
    profile.setPreference("extensions.firebug.netFilterCategory", "image");
    profile.setPreference("extensions.firebug.netexport.Automation", true);
    profile.setPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true);
    profile.setPreference("extensions.firebug.netexport.autoExportActive", true);
    profile.setPreference("extensions.firebug.netexport.autoExportToServer", true);
    profile.setPreference("extensions.firebug.netexport.beaconServerURL", "http://util1.qe.media.pool.corp.sp2.yahoo.com/newmanthan/firebug.php?wfid=101");
    profile.setPreference("extensions.firebug.netexport.sendToConfirmation", false);
    profile.setPreference("extensions.firebug.previousPlacement", 1);
    profile.setPreference("extensions.firebug.script.enableSites", true);
    profile.setPreference("extensions.firebug.showQuickInfoBox", true);
    profile.setPreference("extensions.firebug.toolbarCustomizationDone", true);
    profile.setPreference("extensions.yslow.autorun", true);
    profile.setPreference("extensions.yslow.beaconInfo", "all");
    profile.setPreference("extensions.yslow.beaconUrl", "http://util1.qe.media.pool.corp.sp2.yahoo.com/newmanthan/yslow.php?wfid=101");
    profile.setPreference("extensions.yslow.optinBeacon", true);
    profile.setPreference("general.autoScroll", false);
    profile.setPreference("general.warnOnAboutConfig", false);
    profile.setPreference("gfx.blacklist.direct2d", 3);
    profile.setPreference("gfx.blacklist.layers.direct3d10", 3);
    profile.setPreference("gfx.blacklist.layers.direct3d10-1", 3);
    profile.setPreference("gfx.blacklist.layers.direct3d9", 3);
    profile.setPreference("gfx.blacklist.layers.opengl", 3);
    profile.setPreference("gfx.blacklist.webgl.angle", 3);
    profile.setPreference("gfx.blacklist.webgl.opengl", 3);
    profile.setPreference("intl.charsetmenu.browser.cache", "UTF-8");
    profile.setPreference("layout.spellcheckDefault", 0);
    profile.setPreference("network.cookie.prefsMigrated", true);
    profile.setPreference("places.database.lastMaintenance", 1331591728);
    profile.setPreference("places.history.expiration.transient_current_max_pages", 64408);
    profile.setPreference("places.history.expiration.transient_optimal_database_size", 48876339);
    profile.setPreference("places.last_vacuum", 1317344913);
    profile.setPreference("privacy.sanitize.migrateFx3Prefs", true);
    profile.setPreference("privacy.sanitize.timeSpan", 0);
    profile.setPreference("security.default_personal_cert", "Select Automatically");
    profile.setPreference("security.dialog_enable_delay", 0);
    profile.setPreference("services.sync.clients.lastSync", "0");
    profile.setPreference("services.sync.clients.lastSyncLocal", "0");
    profile.setPreference("services.sync.lastversion", "1.11.0");
    profile.setPreference("services.sync.migrated", true);
    profile.setPreference("services.sync.tabs.lastSync", "0");
    profile.setPreference("services.sync.tabs.lastSyncLocal", "0");
    profile.setPreference("storage.vacuum.last.index", 1);
    profile.setPreference("storage.vacuum.last.places.sqlite", 1330728497);
    profile.setPreference("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey", 1319934792);
    profile.setPreference("xpinstall.whitelist.add", "");
    profile.setPreference("xpinstall.whitelist.add.36", "");
    profile.setPreference("xpinstall.whitelist.required", false);

    //capability.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
    //FirefoxProfile profile = new ProfilesIni().getProfile("Firefox4");
    //profile.setAcceptUntrustedCertificates(true);
    //capability.setCapability(FirefoxDriver.PROFILE, "Firefox8");
    capability.setCapability(FirefoxDriver.PROFILE, profile);


    //capability.setCapability(FirefoxDriver.PROFILE, "");
    capability.setBrowserName("firefox");
    //capability.setBrowserName("chrome");
    capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
    capability.setVersion("4.0");

    URL url;
    try {
    //url = new URL( "http", "10.73.136.137", 5555, "/wd/hub");
    url = new URL( "http", "selgrid1.global.media.corp.yahoo.com", 80, "/wd/hub" );

    //url = new URL("http://10.73.136.123:5555/wd/hub");


    RemoteWebDriver driver = new RemoteWebDriver(url, capability);
    //FirefoxProfile profile = new FirefoxProfile();

    String baseUrl = "http://google.com";
    try {
    Thread.sleep(5000);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    driver.get(baseUrl);
    Assert.assertEquals("Google", driver.getTitle());
    System.out.println(driver.getTitle());
    driver.quit();
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }

    @Test
    public void signIn() {

    }

    }