Javascript 使用SeleniumWebDriver扩展jstree的所有节点
我为我的英语不好道歉,但我真的需要帮助。 我正在尝试用c#实现Internet Explorer的自动化,使用selenium webdriver在外部网站上填写公式(顺便说一句,我有良好的意图:D) 我的问题是在jstree中选择动态加载的节点。选择一个节点后,网站会生成一个新的ul元素,我无法通过xPathes使用selenium的webdriver找到它们,直到单击父节点并在其中生成这些元素。 你能帮我用javascript或codebehind扩展jstree中的所有节点吗? hml代码如下所示Javascript 使用SeleniumWebDriver扩展jstree的所有节点,javascript,c#,selenium-webdriver,jstree,Javascript,C#,Selenium Webdriver,Jstree,我为我的英语不好道歉,但我真的需要帮助。 我正在尝试用c#实现Internet Explorer的自动化,使用selenium webdriver在外部网站上填写公式(顺便说一句,我有良好的意图:D) 我的问题是在jstree中选择动态加载的节点。选择一个节点后,网站会生成一个新的ul元素,我无法通过xPathes使用selenium的webdriver找到它们,直到单击父节点并在其中生成这些元素。 你能帮我用javascript或codebehind扩展jstree中的所有节点吗? hml代码
<div id="tree" class="jstree jstree-0 jstree-focused jstree-classic">
<ul>
<li class="jstree-opened">
<a class="" href="#">
<ins class="jstree-icon"></ins>
Nodetext
</a>
<ul></ul>
</li>
<li class="jstree-closed">
<a class="" href="#">
<ins class="jstree-icon"></ins>
Name of Node
</a>
</li>
</ul>
-
-
想象一下上面的代码是什么样子
我尝试了下面的代码片段,并参与了jstree演示: 请首先检查以上代码是否可以在jstree上工作。 然后您可以使用selenium api:driver.execute_script()在浏览器上执行上述代码,如下所示: Java示例:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return ('#jstree_demo').jstree('open_all');");
JavaScript示例:
driver.executeScript("return ('#jstree_demo').jstree('open_all');");
Python示例:
driver.execute_script("return ('#jstree_demo').jstree('open_all');");
driver.execute_script("return ('#jstree_demo').jstree('open_all');");