2016-06-29 2 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가 하나만 있습니다.

시작시 비어 있습니다. <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")

관련 문제