1

We are testing a web application using selenium and are trying to simulate the fancy tree expand event using the following

driver.findElement(By.xpath("//div[@id='tree']/ul/li/span/span[@class='fancytree-expander']")).click(); 

The fancytree looks like this in the jsp

<div id="tree"></div>

The js code looks like this

$("#tree").fancytree({
    extensions: ["filter"],
    filter: {
        autoApply: true, // Re-apply last filter if lazy data is loaded
        counter: false, // Show a badge with number of matching child nodes near parent icons
        hideExpandedCounter: true, // Hide counter badge, when parent is expanded
        mode: "hide"  // "dimm": Grayout unmatched nodes, "hide": remove unmatched nodes
      },        
    checkbox: true,
    selectMode: 3,
    quicksearch: true,
    source: {
        url: ...
    },


    lazyLoad: function(event, data) {
        ...
    },

    loadError: loadError,

    collapse: function(event, data) {
    }
 });

Can you let us know how can we simulate a fancy tree event click?

Nikhil Das Nomula
  • 1,863
  • 5
  • 31
  • 50

3 Answers3

0

You can execute any javascript code that you want in Selenium.

    FirefoxDriver driver = new FirefoxDriver();
    driver.ExecuteScript("[your fire event javascript code]");
siddhantsomani
  • 1,324
  • 13
  • 12
0

The tree nodes are probably loaded via an Ajax request, so you have to wait until the nodes are rendered. For example using a timeout or trigger something in the fancytree 'init' event.

mar10
  • 14,320
  • 5
  • 39
  • 64
0

Try this.

tree = WebDriverWait(driver, 10).until((EC.element_to_be_clickable((By.XPATH,".//*[@id='left']/ul/li[3]/span/span[1]"))))

ActionChains(driver).click(tree).perform()
Hu Kenneth
  • 240
  • 2
  • 13