I am writing selenium (python) tests for a site that contains a cytoscape.js tree. I am trying to record a ritgh click action on one of the cytoscape's elements (node) but i cannot find a way to do it in python and when i create the test in browser using the selenium IDE is nt recording actions on cytoscape.
Asked
Active
Viewed 196 times
1 Answers
0
To perform a right click in Python, you'll need to use the context_click
action from ActionChains
.
from selenium.webdriver import ActionChains
driver = webdriver.Chrome()
actionChains = ActionChains(driver)
web_element_to_click = driver.find_element_by_id("someId")
actionChains.context_click(web_element_to_click).perform()
If you cannot locate a web element to click (due to dynamic browser page), you may need to click by coordinates instead, by moving the mouse to the coordinates then performing context_click
:
# move_by_offset moves your mouse from its last known location to given x,y offset
ActionChains(driver).move_by_offset(x,y).context_click().perform()

CEH
- 5,701
- 2
- 16
- 40
-
find_element_by_id (or xpath e.t.c.) is not working for cytoscape elements. Working with coordinates is not possible at this case. Is there any way for selenium to work with cytoscape? – galatia Oct 14 '19 at 09:02
-
We would probably need to see the page source HTML to get a better answer for this. If you add it to your original question, I can take a look. – CEH Oct 14 '19 at 13:07