2016-06-29 12 views
1

Intern/Leadfootに、ソースコンテンツまたは少なくとも生のテキストを<div> HTMLタグから取得する方法がありますか?div HTMLタグからページソースデータを取得する方法は?

私はそれを次の参考文献で検索しましたが、成功しませんでした。 https://theintern.github.io/leadfoot/module-leadfoot_Command.html

以下、私のコードを見ることができます。エラーなしで実行されます。しかし、console.log(text)undefinedです。

/*global define*/ 
define(function (require) { 

    function Datasource (remote) { 
    this.remote = remote; 
    } 

    Datasource.prototype = { 
    constructor: Datasource, 

    queryDatasource: function (kibiUrl, title, description, datasource, query) { 
     return this.remote 
     .get(require.toUrl(kibiUrl)) 
     .setFindTimeout(3000) 
     .sleep(3000) 
     .findByCssSelector('input[ng-model="query.title"]') 
      .clearValue() 
      .type(title) 
      .end() 
     .findByCssSelector('input[ng-model="query.description"]') 
      .type(description) 
      .end() 
     .findByCssSelector('option[label="'+ datasource +'"]') 
      .click() 
      .end() 
     .findByName('sqlQuery') 
     .findByClassName('ace_text-input') 
      .type(query) 
      .end() 
     .findByXpath('//button[@class="btn btn-success"]') 
      .click() 
      .end() 
     .sleep(3000) 
     .acceptAlert() 
      .end() 
     .findByCssSelector('div[class="html_preview_content"]') 
     .getVisibleText() 
     .then(function (text) { 
      console.log("SOURCE"); 
      console.log(text); 
      return text; 
     }); 
    } 

    }; 

    return Datasource; 
}); 

これは最初から表示されています。ページには、html_preview_contentクラスを持つdivが1つしかありません。

開始時は空です。 <div class="html_preview_content" kibi-dynamic-html="holder.htmlPreview"></div>

ボタンがクリックされた後に表が作成されます。そして、私はこのテーブルを手に入れたいです。

<div class="html_preview_content" kibi-dynamic-html="holder.htmlPreview"> 
    <style class="ng-scope">thead.custome-header thead{color:#black;}</style> 
    <a href="javascript:showHide('ad90128b-0275-4f95-bda9-78e9a5e9771f');" id="button-ad90128b-0275-4f95-bda9-78e9a5e9771f" class="snippetShowHideButton ng-scope">- Hide </a><span class="ng-scope"> </span> 
    <span class="snippetLabel ng-scope">Preview</span><span class="ng-scope"> (15) </span> 
    <div id="cont-ad90128b-0275-4f95-bda9-78e9a5e9771f" style="display:block" class="ng-scope"> 
     <table class="table table-condensed custome-header"> 
     <thead> 
      <tr> 
       <th>Tables_in_crunchbase</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <td>article</td> 
      </tr> 
      <tr> 
       <td>article_company</td> 
      </tr> 
      <tr> 
       <td>company</td> 
      </tr> 
      <tr> 
       <td>company_city</td> 
      </tr> 
      <tr> 
       <td>company_competitor</td> 
      </tr> 
      <tr> 
       <td>company_countrycode</td> 
      </tr> 
      <tr> 
       <td>company_geolocation</td> 
      </tr> 
      <tr> 
       <td>company_investment</td> 
      </tr> 
      <tr> 
       <td>company_statecode</td> 
      </tr> 
      <tr> 
       <td>investment</td> 
      </tr> 
      <tr> 
       <td>investment_investor</td> 
      </tr> 
      <tr> 
       <td>investor</td> 
      </tr> 
      <tr> 
       <td>investor_city</td> 
      </tr> 
      <tr> 
       <td>investor_countrycode</td> 
      </tr> 
      <tr> 
       <td>investor_statecode</td> 
      </tr> 
     </tbody> 
     </table> 
    </div> 
</div> 
+1

あなたは私の質問を更新しました – jhhoff02

+0

を見てきたいくつかのあなたがしようとしているコードやソースを明記してください。 – trex

+0

ページが何をしているのか分からずに言うのは難しいです。 divにテーブルを置き、 'findByCssSelector(...)。getVisibleText()'を呼び出すと、少なくとも自分のテストではテーブルのテキストが返されます。おそらく、スタイリングの問題(コンテンツが表示されないなど)やタイミングの問題( 'getVisibleText'が呼び出されたときにコンテンツが表示されない)があります。 – jason0x43

答えて

1

あなたのhtml_preview_contentのdiv要素のソースデータを取得するために.findByCssSelector('div[class="html_preview_content"]').getProperty("outerHTML") を使用することができます。そのdivの内側のソースデータのための

それとも.getProperty("innerHTML")

関連する問題