2017-06-01 21 views
1

當前有幾個鏈接假設可以幫助完成此任務:general(1)和specific(2)已接近。使用硒從ExtJS網格行獲取數據

但是(1)不包含任何代碼開始和(2)只包含js單行。

我的問題是如何從extjs生成的行單元格中獲取值?

舉例來說,我已經排元素

div#ext-gen-list-057-r.x-grid3-row.grid-rowcolor-black.grid-fontweight-normal.grid-fontstyle-normal.recordListRow.TableEvenRow.x-grid3-row-first.x-grid3-row-focus 

,其中細胞這樣表示

td.x-grid3-col.x-grid3-cell.x-grid3-td-0.x-grid3-cell-first 

如何它使用python和硒的webdriver值我得到什麼?


UPD

某些搜索後有一些細節透露:

  1. 好像browser.find_element(By.ID, 'element-id')根本不會對ExtJS的網頁儘快上班document.getElementById('element-id')null(糾正我,如果它是錯誤)
  2. 獲取Ext頁面的正確方法是Ext.getBody('body-element-id')

但是,selenium.webdriver.support.uiSelectSelect沒有這樣的方法,允許訪問主體元素。

因此,問題尚未解決。

+0

OT最簡單的測試ExtJS應用程序的方法https://www.sencha.com/products/test/ – pagep

回答

0

可能是這個示例java代碼可以幫助你。它並不直接回答你的問題,但你可以很容易地將它轉換爲python,並深入瞭解解決你的問題。

此代碼從頁面獲取extjs網格,遍歷其行以檢查是否存在包含示例id(1010294)的任何單元格,然後獲取相應的行並單擊該行的第8個單元格。第八個單元格包含一個點擊按鈕。

WebElement editCustTable = driver.findElement(By.className("x-grid-table")); 
List<WebElement> tableRows = editCustTable.findElements(By.tagName("tr")); 
for (Iterator iterator = tableRows.iterator(); iterator.hasNext();) { 
    WebElement row = (WebElement) iterator.next();    
    // if tr contains id = '1010294'    
    if(row.getAttribute("id").contains("1010294")){ 
     List<WebElement> tds = row.findElements(By.tagName("td")); 
     tds.get(8).click(); 
     break; 
     }  
    }