My Selenium Webdriver tests broke recently after upgrading Firefox to version 19. In several of my tests I need to retrieve elements that are on the page but not visible on the browser window, i.e. I would have to scroll right to see them. Since upgrading to Firefox 19 (I upgraded from 15 so this could be an issue since 16) I can only retrieve text for elements that I can see on the browser window. My xpaths properly retrieve all elements, for instance in my following code:
private void buildColumnsMap(){
allColumnHeaders = new HashMap<String,Integer>();
positionToColumnName = new ArrayList<String>();
WebElement columnsRoot = driver.findElement(By.xpath(COLUMNS_ROOT_XPATH));
List <WebElement> columns = columnsRoot.findElements(By.xpath("./td/div/span"));
System.out.println("Number of columns found: " + columns.size());
for(int i = 0; i < columns.size(); ++i){
String columnName = columns.get(i).getText();
System.out.println("Column been inserted: " + columnName);
allColumnHeaders.put(columnName, i);
positionToColumnName.add(columnName);
}
}
The list "columns" has a size of 38 but in my browser window I can only see 10 columns without having to scroll so when I go to put the column names into my objects I get 10 column names then all blanks.
Number of columns found: 38
Column been inserted: Date/Time
Column been inserted: Endpoint1
Column been inserted: Endpoint2
Column been inserted: Duration
Column been inserted: Codec1
Column been inserted: Codec2
Column been inserted: Avg MOS1
Column been inserted: Avg MOS2
Column been inserted: Avg Latency1 (ms)
Column been inserted: Avg Latency2 (ms)
Column been inserted: Avg Jitter1 (ms)
Column been inserted:
Column been inserted:
...
...
This worked for me perfectly fine in Firefox 15 but is now broken. Has anyone ran into something similar and found a work around? Or is there a way to "scroll to an element" as to force the scrolling and therefore make it visible on the screen?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…