2017-01-05 18 views
0

我無法找到此元素;它顯示如下錯誤:高速緩存中未找到元素 - 可能自查找該頁面後頁面已發生變化有關此錯誤的文檔

元素在緩存中沒有發現 - 也許是頁面已經改變,因爲它 被查找有關文檔此錯誤

WebElement w4= d.findElement(By.xpath("//input[@name='businessPartner' 
       and @oninput='isc_OBSelectorItem_1.$303()']")); 
    expcitlyWait(w4); 
    w4.sendKeys("DURIAN INDUSTRIES LTD"); 
    w4.sendKeys(Keys.TAB); 
    w4.sendKeys(Keys.ENTER); 
} 

例輸入這應該是發現:

<input id="isc_T3" 
name="businessPartner" 
oninput="isc_OBSelectorItem_1.$303()" 
class="OBFormFieldSelectInputRequired" 
type="TEXT" tabindex="2239" 
style="WIDTH:233px;HEIGHT:19px;-moz-user-focus:normal;" 
autocomplete="OFF" 
spellcheck="true" 
$187="$188" 
$186="isc_OBSelectorItem_1" 
handlenativeevents="false" 
/> 
+0

看看你的頁面,是否有這個@oninput函數的輸入? 您是否在使用selenium和php? 303美元的部分看起來不對我 –

+0

@DoktorOSwaldo是oninput函數在那裏,我用java與硒。

+0

但在本例中,名稱不存在。你可以發佈你試圖抓取的整個對象的html,(一個對象應該是足夠的) –

回答

0

好的問題似乎是,你引用爲「w4」的元素不再存在,或不在同一個地方。 如果頁面上的某些內容發生了變化,您的xpath調用和w4調用之間會發生此錯誤嘗試使用絕對Xpath。 (找到w4,並在d上找到輸入)。 所以你的代碼應該看起來像這樣:

expcitlyWait(d.findElement(By.xpath("//input[@name='businessPartner' 
      and @oninput='isc_OBSelectorItem_1.$303()']"))); 
d.findElement(By.xpath("//input[@name='businessPartner' 
      and @oninput='isc_OBSelectorItem_1.$303()']")) 
      .sendKeys("DURIAN INDUSTRIES LTD"); 
d.findElement(By.xpath("//input[@name='businessPartner' 
      and @oninput='isc_OBSelectorItem_1.$303()']")) 
      .sendKeys(Keys.TAB); 
d.findElement(By.xpath("//input[@name='businessPartner' 
      and @oninput='isc_OBSelectorItem_1.$303()']")) 
      .sendKeys(Keys.ENTER); 
+0

我試過絕對x路徑,同樣的問題, - // table [@ id ='isc_T6']/tbody/tr [1]/td [1]/input –

+0

嘗試我的編輯,如果失敗,看看它失敗的位置 –

+0

我嘗試了你的代碼,仍然得到相同的問題 - 導演:org.openqa.selenium.StaleElementReferenceException:在緩存中找不到的元素 - 可能頁面已經改變,因爲它被查找 有關此錯誤的文檔, –

相關問題