Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

FirefoxDriver fails to identify "Start Book Creator" button on https://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Main+Page

  • No replies
  • 1 has this problem
  • 2 views
more options

Environment:

=

Firefox version: 48 OS: Windows 10 64-bit FirefoxDriver version: geckodriver-v0.11.1-win64 Selenium Version: 3.0.1 Java Version: 1.8.0

Description:

==

An automation script written using Selenium WebDriver, Java could not find an element on a web page. FirefoxDriver fails to identify "Start Book Creator" button on https://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Main+Page.

The following source code fails to identify, while ChromeDriver works perfectly.

package testcases;

import org.testng.annotations.Test; import org.testng.annotations.BeforeMethod; import org.testng.annotations.AfterMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeSuite; import org.testng.annotations.AfterSuite; import static org.testng.Assert.*;

import java.util.regex.Pattern; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.chrome.*; import org.openqa.selenium.support.ui.Select;

public class BookCreator {

 private WebDriver driver;
 private String baseUrl;
 private boolean acceptNextAlert = true;
 /*
 @Test(dataProvider = "dp")
 public void f(Integer n, String s) {
 }
 */
 
 @BeforeMethod
 public void beforeMethod() {
 }
 @AfterMethod
 public void afterMethod() {
 }


 @DataProvider
 public Object[][] dp() {
   return new Object[][] {
     new Object[] { 1, "a" },
     new Object[] { 2, "b" },
   };
 }
 @BeforeClass(alwaysRun = true)
 public void setUp() throws Exception {

System.setProperty("webdriver.gecko.driver", "E:\\WikipediaBookCreator\\SeleniumLibraries\\geckodriver.exe"); //System.setProperty("webdriver.chrome.driver", "E:\\WikipediaBookCreator\\SeleniumLibraries\\chromedriver.exe"); driver = new FirefoxDriver();

   baseUrl = "https://en.wikipedia.org";
   driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
 }
 @AfterClass
 public void afterClass() {
 }
 @BeforeTest
 public void beforeTest() {
 }
 @AfterTest
 public void afterTest() {
 }
 @BeforeSuite
 public void beforeSuite() {
 }
 @AfterSuite
 public void afterSuite() {
 }
 @Test
 public void testCase()
 {
   driver.get(baseUrl + "/wiki/Main_Page");
   
   /********************************************************************/
   // Click on "Create a book" link under Print section in the homepage
   driver.findElement(By.linkText("Create a book")).click();
   
   // Click on "Start Book Creator" button
   /*  @Bug in Firefox
    *  ===============
    *  There is a single button on the page bearing label "Start Book Creator"
    *  FirefoxDriver fails to identify the button on the page, but,
    *  ChromeDriver identifies it correctly and proceeds further.
    */ 
   driver.findElement(By.tagName("button")).click();
   
   /* This code is to handle if a confirmation alert asking to proceed with creating a book if a 
    * book creation is already in process. 
    */
   //driver.findElement(By.name("confirm")).click();
   /******************************************************/
   // Code to search for Selenium page and navigate to it
   driver.findElement(By.id("searchInput")).click();
   driver.findElement(By.id("searchInput")).clear();
   driver.findElement(By.id("searchInput")).sendKeys("Selenium");
   driver.findElement(By.id("searchInput")).sendKeys(Keys.ENTER);
   //driver.findElement(By.id("searchButton")).click();
   // Code to add Selenium page to the book
   driver.findElement(By.id("coll-add_article")).click();
   
   /*****************************************************/
   // Code to search for JScript page and navigate to it
   driver.findElement(By.id("searchInput")).click();
   driver.findElement(By.id("searchInput")).clear();
   driver.findElement(By.id("searchInput")).sendKeys("JScript");
   driver.findElement(By.id("searchInput")).sendKeys(Keys.ENTER);
   //driver.findElement(By.id("searchButton")).click();
   // Code to add JScript page to the book
   driver.findElement(By.id("coll-add_article")).click();
   
   /******************************************************/
   // Code to click on "Show book (2 pages)" 
   driver.findElement(By.xpath(".//*[@id='coll-book_creator_box']/a[2]")).click();
   // Code to enter book title
   driver.findElement(By.id("titleInput")).click();
   driver.findElement(By.id("titleInput")).clear();
   driver.findElement(By.id("titleInput")).sendKeys("Book Creator from Wikipedia");
   // Code to enter book subtitle
   driver.findElement(By.id("subtitleInput")).click();
   driver.findElement(By.id("subtitleInput")).clear();
   driver.findElement(By.id("subtitleInput")).sendKeys("Using Automation");
   // Code to click on "Download" button on "Manage Your Book" page
   driver.findElement(By.id("downloadButton")).click();
   
   /**************************************************/
   // Code to display context menu by performing right-click on "Download the file" link.
   rightClick(driver.findElement(By.linkText("Download the file")));
   
   //driver.quit(); 
 }
 public void rightClick(WebElement element) {

try { Actions action = new Actions(driver).contextClick(element); action.build().perform();

System.out.println("Sucessfully Right clicked on the element"); } catch (StaleElementReferenceException e) { System.out.println("Element is not attached to the page document " + e.getStackTrace()); } catch (NoSuchElementException e) { System.out.println("Element " + element + " was not found in DOM " + e.getStackTrace()); } catch (Exception e) { System.out.println("Element " + element + " was not clickable " + e.getStackTrace()); } } }

Steps to reproduce:

====

1. Launch "Eclipse" 2. Create a Java Project 3. Add external JARs to project i.e., selenium-server-standalone-3.0.1.jar, client-combined-3.0.1-nodeps.jar 4. Enable TestNG in eclipse, by installing TestNG from Help -> Install new software. 5. Create new Java file in the project and paste the above source code. 6. Run -> Run as -> TestNG Test

Expected behavior:

====

Should launch the browser, and perform all the tasks in the source code.

Actual behavior:

==

Line 97 of the code i.e., driver.findElement(By.linkText("Create a book")).click(); fails to identify the element on the page. But, this code when customized for ChromeDriver runs perfectly.

Environment: =========== Firefox version: 48 OS: Windows 10 64-bit FirefoxDriver version: geckodriver-v0.11.1-win64 Selenium Version: 3.0.1 Java Version: 1.8.0 Description: ========== An automation script written using Selenium WebDriver, Java could not find an element on a web page. FirefoxDriver fails to identify "Start Book Creator" button on https://en.wikipedia.org/w/index.php?title=Special:Book&bookcmd=book_creator&referer=Main+Page. The following source code fails to identify, while ChromeDriver works perfectly. package testcases; import org.testng.annotations.Test; import org.testng.annotations.BeforeMethod; import org.testng.annotations.AfterMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeSuite; import org.testng.annotations.AfterSuite; import static org.testng.Assert.*; import java.util.regex.Pattern; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.chrome.*; import org.openqa.selenium.support.ui.Select; public class BookCreator { private WebDriver driver; private String baseUrl; private boolean acceptNextAlert = true; /* @Test(dataProvider = "dp") public void f(Integer n, String s) { } */ @BeforeMethod public void beforeMethod() { } @AfterMethod public void afterMethod() { } @DataProvider public Object[][] dp() { return new Object[][] { new Object[] { 1, "a" }, new Object[] { 2, "b" }, }; } @BeforeClass(alwaysRun = true) public void setUp() throws Exception { System.setProperty("webdriver.gecko.driver", "E:\\WikipediaBookCreator\\SeleniumLibraries\\geckodriver.exe"); //System.setProperty("webdriver.chrome.driver", "E:\\WikipediaBookCreator\\SeleniumLibraries\\chromedriver.exe"); driver = new FirefoxDriver(); baseUrl = "https://en.wikipedia.org"; driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS); } @AfterClass public void afterClass() { } @BeforeTest public void beforeTest() { } @AfterTest public void afterTest() { } @BeforeSuite public void beforeSuite() { } @AfterSuite public void afterSuite() { } @Test public void testCase() { driver.get(baseUrl + "/wiki/Main_Page"); /********************************************************************/ // Click on "Create a book" link under Print section in the homepage driver.findElement(By.linkText("Create a book")).click(); // Click on "Start Book Creator" button /* @Bug in Firefox * =============== * There is a single button on the page bearing label "Start Book Creator" * FirefoxDriver fails to identify the button on the page, but, * ChromeDriver identifies it correctly and proceeds further. */ driver.findElement(By.tagName("button")).click(); /* This code is to handle if a confirmation alert asking to proceed with creating a book if a * book creation is already in process. */ //driver.findElement(By.name("confirm")).click(); /******************************************************/ // Code to search for Selenium page and navigate to it driver.findElement(By.id("searchInput")).click(); driver.findElement(By.id("searchInput")).clear(); driver.findElement(By.id("searchInput")).sendKeys("Selenium"); driver.findElement(By.id("searchInput")).sendKeys(Keys.ENTER); //driver.findElement(By.id("searchButton")).click(); // Code to add Selenium page to the book driver.findElement(By.id("coll-add_article")).click(); /*****************************************************/ // Code to search for JScript page and navigate to it driver.findElement(By.id("searchInput")).click(); driver.findElement(By.id("searchInput")).clear(); driver.findElement(By.id("searchInput")).sendKeys("JScript"); driver.findElement(By.id("searchInput")).sendKeys(Keys.ENTER); //driver.findElement(By.id("searchButton")).click(); // Code to add JScript page to the book driver.findElement(By.id("coll-add_article")).click(); /******************************************************/ // Code to click on "Show book (2 pages)" driver.findElement(By.xpath(".//*[@id='coll-book_creator_box']/a[2]")).click(); // Code to enter book title driver.findElement(By.id("titleInput")).click(); driver.findElement(By.id("titleInput")).clear(); driver.findElement(By.id("titleInput")).sendKeys("Book Creator from Wikipedia"); // Code to enter book subtitle driver.findElement(By.id("subtitleInput")).click(); driver.findElement(By.id("subtitleInput")).clear(); driver.findElement(By.id("subtitleInput")).sendKeys("Using Automation"); // Code to click on "Download" button on "Manage Your Book" page driver.findElement(By.id("downloadButton")).click(); /**************************************************/ // Code to display context menu by performing right-click on "Download the file" link. rightClick(driver.findElement(By.linkText("Download the file"))); //driver.quit(); } public void rightClick(WebElement element) { try { Actions action = new Actions(driver).contextClick(element); action.build().perform(); System.out.println("Sucessfully Right clicked on the element"); } catch (StaleElementReferenceException e) { System.out.println("Element is not attached to the page document " + e.getStackTrace()); } catch (NoSuchElementException e) { System.out.println("Element " + element + " was not found in DOM " + e.getStackTrace()); } catch (Exception e) { System.out.println("Element " + element + " was not clickable " + e.getStackTrace()); } } } Steps to reproduce: ================ 1. Launch "Eclipse" 2. Create a Java Project 3. Add external JARs to project i.e., selenium-server-standalone-3.0.1.jar, client-combined-3.0.1-nodeps.jar 4. Enable TestNG in eclipse, by installing TestNG from Help -> Install new software. 5. Create new Java file in the project and paste the above source code. 6. Run -> Run as -> TestNG Test Expected behavior: ================ Should launch the browser, and perform all the tasks in the source code. Actual behavior: ============== Line 97 of the code i.e., driver.findElement(By.linkText("Create a book")).click(); fails to identify the element on the page. But, this code when customized for ChromeDriver runs perfectly.