Codota Logo
FirefoxDriver
Code IndexAdd Codota to your IDE (free)

How to use
FirefoxDriver
in
org.openqa.selenium.firefox

Best Java code snippets using org.openqa.selenium.firefox.FirefoxDriver (Showing top 20 results out of 918)

Refine searchRefine arrow

  • WebDriver
  • WebElement
  • WebDriverWait
  • ChromeDriver
  • InternetExplorerDriver
  • Actions
  • Common ways to obtain FirefoxDriver
private void myMethod () {
FirefoxDriver f =
  • Codota Iconnew FirefoxDriver()
  • Codota IconCapabilities desiredCapabilities;new FirefoxDriver(desiredCapabilities)
  • Codota IconFirefoxOptions options;new FirefoxDriver(options)
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

WebDriver myTestDriver = new FirefoxDriver();
myTestDriver.get("...blablabla....");
myTestDriver.manage().window().maximize();
myTestDriver.findElement(By.xpath("//input[@value = 'alert']")).click();
Alert javascriptAlert = myTestDriver.switchTo().alert();
origin: stackoverflow.com

 FirefoxDriver driver = new FirefoxDriver();

driver.get("http://localhost:8080/page");

File file = null;

try {
  file = new File(YourClass.class.getClassLoader().getResource("file.txt").toURI());
} catch (URISyntaxException e) {
  e.printStackTrace();
}

Assert.assertTrue(file.exists()); 

WebElement browseButton = driver.findElement(By.id("myfile"));
browseButton.sendKeys(file.getAbsolutePath());
origin: stackoverflow.com

 import org.openqa.selenium.firefox.FirefoxDriver;

public class Test {
  public static void main(String[] args) {
    try{
      FirefoxDriver driver = new FirefoxDriver();
      driver.get("http:www.yahoo.com");
    } catch(Exception e){
      e.printStackTrace();
    }
  }
}
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, 30);
driver.get("...");

// move the cursor to the menu Product
WebElement element = driver.findElement(By.xpath("drop down button")).click();
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("drop down item"))).click();
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://connectatgrace.org/im-new/what-to-expect");
WebElement content = driver.findElement(By.id("content full-width"));
Actions builder = new Actions(driver);
builder.moveToElement(content, 0, 0).clickAndHold().moveToElement(content, 
  content.getSize().getWidth(), content1.getSize().getHeight()).release();
builder.build().perform();
content.sendKeys(Keys.chord(Keys.CONTROL, "c"));
System.out.println("CLICKED");
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com");
driver.manage().window().maximize();
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Ankush");
element.submit();
origin: stackoverflow.com

 public class Mhover {

public static void main(String[] args){

  WebDriver driver = new FirefoxDriver();
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.get("http://www.google.com");
  WebElement ele = driver.findElement(By.id("gbqfba"));
  Actions action = new Actions(driver);
  action.moveToElement(ele).build().perform();


}

}
origin: stackoverflow.com

WebDriver driver = new FirefoxDriver();
 driver.get("https://play.google.com/store/apps/details?id=com.facebook.orca");
 WebElement permission = driver.findElement(By.className("id-view-permissions-details"));
 permission.click();
 WebDriverWait wait = new WebDriverWait(driver, 10);
 WebElement modalPopup = driver.findElement(By.className("modal-dialog"));
 wait.until(ExpectedConditions.visibilityOf(modalPopup));
 String xpath = "//ul[@class='bucket-description']//li[text()='precise location (GPS and network-based)']";
 WebElement whatTheHeck = driver.findElement(By.xpath(xpath));
 System.out.println(whatTheHeck.getText());
 driver.quit();
origin: stackoverflow.com

 public static void main(String[] args) {

  WebDriver driver = new FirefoxDriver();
  driver.get("http://www.google.com");
  WebElement element = driver.findElement(By.name("q"));
  element.sendKeys("Cheese!\n"); // send also a "\n"
  element.submit();

  // wait until the google page shows the result
  WebElement myDynamicElement = (new WebDriverWait(driver, 10))
       .until(ExpectedConditions.presenceOfElementLocated(By.id("resultStats")));

  List<WebElement> findElements = driver.findElements(By.xpath("//*[@id='rso']//h3/a"));

  // this are all the links you like to visit
  for (WebElement webElement : findElements)
  {
    System.out.println(webElement.getAttribute("href"));
  }
}
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();

// And now use this to visit Google
driver.get("http://www.google.com");

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

if (element.getTagName().equalsIgnoreCase("input") 
    && element.getAttribute("type").equalsIgnoreCase("text")) {
  System.out.println("its a textbox");
}
origin: stackoverflow.com

WebDriver driver = new FirefoxDriver();
 driver.get("http://imgur.com/");
 driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
 driver.manage().window().maximize();
 driver.findElement(By.partialLinkText("sign in")).click();
 WebDriverWait wait = new WebDriverWait(driver, 30);
 wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.className("cboxIframe")));
 wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("f")));
 driver.findElement(By.name("username")).sendKeys("abcd");
 driver.findElement(By.xpath(".//*[@id='password']/input")).sendKeys("abcd");
 driver.close();
 driver.quit();
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();
driver.get("http://www.htmlcodetutorial.com/forms/_SELECT_MULTIPLE.html");
List<WebElement> options = driver.findElements(By.xpath("//select[@name='toppings']//option"));

// Values to select
List<String> values =  Arrays.asList("onions", "olives");

// Select all the options
Actions act = new Actions(driver);
act.keyDown(Keys.CONTROL);
for (WebElement option: options){
  if(values.contains(option.getText())) {
    act.click(option);
  }
}
act.keyUp(Keys.CONTROL);
act.perform();

driver.quit();
origin: stackoverflow.com

public static void main(String args[]) {
   WebDriver driver = new FirefoxDriver();
   driver.get("http://amazon.in");
   driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
   Actions action = new Actions(driver);
   WebElement search = driver.findElement(By.xpath(".//*[@id='twotabsearchtextbox']"));
   //Search using actions by combining entering search string and then hit enter
   action.click(search).sendKeys("Test").sendKeys(Keys.RETURN).build().perform();
   // This also works where it does the same without actions class
   search.sendKeys("test");
   search.sendKeys(Keys.RETURN);
 }
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();
driver.get("http://stackoverflow.com");
WebElement element = driver.findElement(By.linkText("Stack Overflow"));
// set the target _blank on the link
((JavascriptExecutor)driver).executeScript("arguments[0].target='_blank';", element);
// click the link
element.click();
// set the context to the new window
driver.switchTo().window(driver.getWindowHandles().toArray()[1]);
origin: stackoverflow.com

 WebDriver driver = new FirefoxDriver();
driver.get("http://curatorsofsweden.com/archive/");

By linkSelector = By.cssSelector("div[class='block block--archive'] a");

WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.presenceOfElementLocated(linkSelector));

List<WebElement> linkElements = driver.findElements(linkSelector);
for (WebElement linkElement : linkElements) {
  String link = linkElement.getAttribute("href");
  System.out.println("LINK " + link);
}
driver.quit();
origin: galenframework/galen

public static WebDriver getDriver(String browserType, boolean headless){
  
  if ( StringUtils.isEmpty(browserType) || FIREFOX.equals(browserType)) {
    return new FirefoxDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType, headless));
  }
  else if (CHROME.equals(browserType)) {
    return new ChromeDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType, headless));
  }
  else if (IE.equals(browserType)) {
    return new InternetExplorerDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType, false));
  }
  else if (PHANTOMJS.equals(browserType)) {
    return new PhantomJSDriver();
  }
  else if (SAFARI.equals(browserType)) {
    return new SafariDriver();
  }
  else if (EDGE.equals(browserType)) {
    return new EdgeDriver();
  }
  else {
    throw new RuntimeException(String.format("Unknown browser type: \"%s\"", browserType));
  }
}
origin: stackoverflow.com

 public class Wiki

{

   @Test
   public void createAccount() throws InterruptedException
   {
   WebDriver driver = new FirefoxDriver();
   WebDriverWait wait=new WebDriverWait(driver,60);
   driver.get("http://en.wikipedia.org/wiki/Main_Page");
   driver.findElement(By.linkText("Create account")).click();
   wait.until(ExpectedConditions.titleContains("Create account - Wikipedia, the free encyclopedia"));
   Assert.assertEquals("Create account - Wikipedia, the free encyclopedia",driver.getTitle());
   driver.quit();
   }

}
origin: stackoverflow.com

WebDriver driver = new FirefoxDriver();
   driver.get("http://stackoverflow.com/");
   WebElement e = driver.findElement(By.xpath(".//*[@id='nav-questions']"));       
   Actions action = new Actions(driver); 
   action.keyDown(Keys.CONTROL).build().perform(); //press control key
   e.click();
   Thread.sleep(10000); // wait till your page loads in new tab
   action.keyUp(Keys.CONTROL).build().perform(); //release control key
   driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "\t"); //move to new tab
   driver.navigate().refresh(); // refresh page
   driver.findElement(By.xpath(".//*[@id='hlogo']/a")).click(); //perform any action in new tab. I am just clicking logo
   driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "\t"); //switch to first tab
   driver.navigate().refresh(); 
   driver.findElement(By.xpath(".//*[@id='hlogo']/a")).click();// refresh first tab & continue with your further work.I am just clicking logo
origin: code4craft/webmagic

  mDriver = new RemoteWebDriver(new URL(driver), sCaps);
} else if (driver.equals(DRIVER_FIREFOX)) {
  mDriver = new FirefoxDriver(sCaps);
} else if (driver.equals(DRIVER_CHROME)) {
  mDriver = new ChromeDriver(sCaps);
} else if (driver.equals(DRIVER_PHANTOMJS)) {
  mDriver = new PhantomJSDriver(sCaps);
origin: stackoverflow.com

 public static void main(String[] args) throws Exception {
  WebDriver driver = new FirefoxDriver();
  driver.get("http://www.twitch.tv/NAME_OF_CHANNEL/chat?opentga=1");

  WebDriverWait initialWait = new WebDriverWait(driver, 60);
  WebElement commentsContainer = initialWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("ul.chat-lines")));
  if(commentsContainer == null)
    throw new Exception("Page unresponsive!!!");

  int numberOfComments = commentsContainer.findElements(By.cssSelector("div[id^=ember]")).size() + 1;
  while(true) {
    String newCommentSelector = "chat-lines > div:nth-child(" + numberOfComments + ")";
    WebElement newComment = (new WebDriverWait(driver, 60))
     .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(newCommentSelector)));
    if(newComment == null) continue;

    numberOfComments++;

    System.out.println(newComment.getText());
  }
}
org.openqa.selenium.firefoxFirefoxDriver

Javadoc

An implementation of the {#link WebDriver} interface that drives Firefox.

The best way to construct a FirefoxDriver with various options is to make use of the FirefoxOptions, like so:

 
FirefoxOptions options = new FirefoxOptions() 
.setProfile(new FirefoxProfile()); 
WebDriver driver = new FirefoxDriver(options); 

Most used methods

  • <init>
  • manage
  • get
  • getTitle
  • quit
  • connectTo
  • findElement
  • findElementByCssSelector
  • findElements
  • ExecuteScript
  • FindElement
  • FindElementByXPath
  • FindElement,
  • FindElementByXPath,
  • Manage,
  • Quit,
  • close,
  • convertToJsObject,
  • convertToJsObjects,
  • dropCapabilities,
  • execute,
  • executeScript

Popular in Java

  • Creating JSON documents from java classes using gson
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now