2016-07-06 13 views
0

私は自動化で新しいです。私は私の会社のウェブサイトの1ページを自動化します。 スクリプティング中に、エラーコードとして「ラベルが認識されていないため、対話できないかもしれませんが、ラベルテキストが正しく表示され、クリック可能です。要素表示されない

私はこのラベル要素を見つけるためにほとんどすべての方法を試していますが、それでもエラーはそのままです。だから私はラベルテキストのために私のwebdriverがこのラベルを検出せず、このエラーを記録すると仮定しています。

私の懸念があります。 Label Text wedriverで使用されているColorがラベルを表示可能と見なしていない可能性がありますか?

Kindly Advise。コードやHTML

Public WebElement GetDataSourceListByID(List<WebElement> Tables){ 
     WebElement lstSearchFields;  
     WebElement fieldTable = null; 
     WebElement weTemp = null; 
     String tDataSourceId = null; 
     Actions Visible;    

     for(WebElement we : Tables){ 
      List<WebElement> x = we.findElements(By.xpath("//*/div[contains(@id, 'treeview')]"));   
      for (WebElement c : x){ 
       System.out.println("____________"+c.getAttribute("id")); 
       c.findElement(By.xpath("//*/span[contains(text(), 'Manage Stores')]")).click(); 
      } 

     } 

     return fieldTable;    
    } 

HTML CODE

<div class="x-grid-item-container" style="width: 260px;"> 
<table id="treeview-1165-record-310" data-boundview="treeview-1165" data-recordid="310" data-recordindex="0" class="x-grid-item x-grid-item-selected" style=";width:0" cellpadding="0" cellspacing="0"> 
<tbody> 
<tr class=" x-grid-row" data-qtip="" data-qtitle=""> 
<td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
<div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-store-png"><span class="x-tree-node-text ">Stores</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 refreshIcon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-311" data-boundview="treeview-1165" data-recordid="311" data-recordindex="1" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="dvp-tree-node-disabled x-grid-tree-node-expanded x-grid-row" data-qtip="" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-workfolder-png"><span class="x-tree-node-text ">Search Folders</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-318" data-boundview="treeview-1165" data-recordid="318" data-recordindex="2" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="dvp-tree-node-disabled x-grid-row" data-qtip="M_test" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-line" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-workfolder-png"><span class="x-tree-node-text ">M_test</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-319" data-boundview="treeview-1165" data-recordid="319" data-recordindex="3" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="Darshan (3)" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-line" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-end" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-searchfolder-png"><span class="x-tree-node-text ">Darshan (3)</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-312" data-boundview="treeview-1165" data-recordid="312" data-recordindex="4" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="dvp-tree-node-disabled x-grid-tree-node-expanded x-grid-row" data-qtip="" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-end-plus x-tree-expander" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-parent edge-setting"><span class="x-tree-node-text ">Manage Data Source</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-322" data-boundview="treeview-1165" data-recordid="322" data-recordindex="5" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-empty" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-store-png"><span class="x-tree-node-text ">Manage Stores</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-323" data-boundview="treeview-1165" data-recordid="323" data-recordindex="6" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-empty" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-connector-png"><span class="x-tree-node-text ">Manage Connectors</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 
<table id="treeview-1165-record-324" data-boundview="treeview-1165" data-recordid="324" data-recordindex="7" class="x-grid-item" style=";width:0" cellpadding="0" cellspacing="0"> 
    <tbody> 
     <tr class="x-grid-tree-node-leaf x-grid-row" data-qtip="" data-qtitle=""> 
      <td class="x-grid-cell x-grid-td x-grid-cell-treecolumn-1163 edgeThemeColor x-grid-cell-treecolumn x-grid-cell-first x-unselectable" style="width: 220px;" tabindex="-1" data-columnid="treecolumn-1163"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-treecolumn" style="text-align:left;"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-empty" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class=" x-tree-elbow-img x-tree-elbow-end" role="presentation"><img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" role="presentation" class=" x-tree-icon x-tree-icon-leaf edge-rule-png"><span class="x-tree-node-text ">Manage Rules</span></div> 
      </td> 
      <td class="x-grid-cell x-grid-td x-grid-cell-actioncolumn-1164 x-action-col-cell x-grid-cell-last x-unselectable" style="width:40px;" tabindex="-1" data-columnid="actioncolumn-1164"> 
       <div unselectable="on" class="x-grid-cell-inner x-grid-cell-inner-action-col" style="text-align:left;"><img alt="" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-action-col-icon x-action-col-0 no-icon" data-qtip="Refresh"></div> 
      </td> 
     </tr> 
    </tbody> 
</table> 

+0

セレンコードとHTMLコードも共有できますか? –

+0

イメージではなく、フォーマットされたコードとしてhtmlを提供してください。私はあなたのhtmlの中で '

答えて

0

forループだけでいくつかの変更を加えました。親切に以下のforループを置き換え、コードを実行してみてください。

for(WebElement we:Tables) { List x = we.findElements(By.cssSelector( "table [id^= 'treeview']"));
for(WebElement c:x) { System.out.println( "____________" + c.getAttribute( "id")); c.findElement(By.xpath( "// * [店舗管理])]"))。 } }

id値の先頭に 'treeview'というIDが表示されていますので、私はCSSのセレクタ "id ^"を使用しました。 - IDは 'treeview'で始まります。

あなたの問題が解決されることを願っています。それ以上の助けが必要な場合は、バックを投稿してください。

+0

正常に動作します。ありがとうございます。 – Ishekh

+0

Ishekhありがとう、あなたの問題を解決したら私の答えに投票してください。他の人がそれを利用することができます。 –

0

を追加アドバンス

おかげ

はボタン

をクリックする前に、明示的な待機を使用してみてください
WebDriverWait wait = new WebDriverWait(driver, 10); 
    wait.until(ExpectedConditions.elementToBeClickable(By.id("someid"))); 
+0

私はすでにこれを試してみませんが、私の場合は動作しません。詳細については、HTMLコードの追加を参照してください。 – Ishekh

関連する問題