I am writing a test script using selenium in Python. I have a webpage containing an object in the form of a tree, for example:

I want to go through the menu to go to the desired directory. The corresponding HTML for plus / minus signs is as follows:
<a onclick="changeTree('tree', 'close.gif', 'open.gif');"> <img id="someid" src="open.gif" /> </a>
The src attribute of an image can be either open.gif or close.gif .
I can determine if there is a plus or minus just by checking the src attribute of the img tag. I can also easily access the parent tag a using .find_element_by_xpath("..") .
The problem is that I cannot perform the action of clicking on not an img tag a.
webdriver.Actions(driver).move_to_element(el).click().perform() tried webdriver.Actions(driver).move_to_element(el).click().perform() ; but it didnโt work.
I think I should mention that there is no problem accessing the elements, since I can print all their attributes; I just canโt take action on them. Any help?
EDIT 1:
Here is the js code to collapse and expand the tree:
function changeTree(tree, image1, image2) { if (!isTreeviewLocked(tree)) { var image = document.getElementById("treeViewImage" + tree); if (image.src.indexOf(image1)!=-1) { image.src = image2; } else { image.src = image1; } if (document.getElementById("treeView" + tree).innerHTML == "") { return true; } else { changeMenu("treeView" + tree); return false; } } else { return false; } }
EDIT 2:
I googled for several hours and found that there was a problem with triggering Javascript events and click actions from the web driver. Also, I have a span tag on my webpage with an onclick event and I also have this problem.
python javascript-events dom-events selenium click
Zeinab Abbasimazar
source share