2017-12-07 26 views
1

I次のコードを持っている:私は赤でマークされ<i class="jstree-icon jstree-ocl">、をクリックする必要があり、私のセレンのテストのために選択要素

<div id="filebrowser" class="jstree jstree-1 jstree-grid-cell jstree-default jstree-checkbox-selection" role="tree" aria-multiselectable="true" tabindex="0" aria-activedescendant="-3" aria-busy="false" aria-selected="false"> 
    <ul class="jstree-container-ul jstree-children" role="group"> 
     <li role="treeitem" aria-selected="false" aria-level="1" aria-labelledby="-3_anchor" aria-expanded="false" id="-3" class="jstree-node jstree-last jstree-closed" aria-busy="false"> 
      <i class="jstree-icon jstree-ocl" role="presentation"></i> 
      <a class="jstree-anchor jstree-grid-col-0" href="#" tabindex="-1" id="-3_anchor" title="/"> 
       <i class="jstree-icon jstree-checkbox" role="presentation"></i> 
       <i class="jstree-icon jstree-themeicon glyphicon glyphicon-folder-close jstree-themeicon-custom" role="presentation"></i>/ 
      </a> 
     </li> 
    </ul> 
</div> 

Screenshot

をスクリーンショット。私はまた、title= attributeを持つ要素を持っており、<a>リストにこれをクリックしたいと思います。それは可能ですか?背景については

:私は、グローバル値として自分の名前を設定することで、これらのファイルに与えられたjstreeと点が異なるファイルを選択したいと思います。私は"/""etc/""testdirectory"、その後"test_file.txt"を選択したい場合。次のコード行を使用することができます<i class="jstree-icon jstree-ocl">として表さWebElementをクリックし

答えて

0

driver.find_element_by_xpath("//li[@role='treeitem']/i[@class='jstree-icon jstree-ocl' and @role='presentation']").click() 

しかしHTMLを見て、我々は次のように<a>タグにclick()メソッドを呼び出すする必要がありそうです。

driver.find_element_by_xpath("//li[@role='treeitem']//a[@class='jstree-anchor jstree-grid-col-0']").click() 
+0

このケースでは機能しますが、「tit」の要素としてクリックして実装する可能性がありますそれの隣に "le"属性がありますか?この下に示すように 複数のアンカーがある場合には動作しません。 [スクリーンショット](http://prntscr.com/hkbc2q) – thraizz

+0

**対話型として設計されている任意の要素**クリックすることができる。**。装飾のように**属性**を扱います。私の** 'Answer' ** **' Accept'は** 'Answer' ** * Answer''私の**の横にチェックマークをクリックして**あなたの** 'Question'にしてください仕出し料理している場合*はVoteDown矢印のすぐ下にあるので、目盛りが緑色に変わります。ありがとう – DebanjanB