0
檢索XML形式我將直接切入正題和問題:與Python硒
首先,這裏是我下面的代碼(這很簡單):
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
el = driver.find_element_by_id("id1")
el.clear()
el.send_keys("2147000001")
el = driver.find_element_by_id("id2")
el.click()
el = driver.find_element_by_id("id3")
el.click()
textbox = driver.find_element_by_id("id4")
asd = textbox.get_attribute("innerHTML")
print asd
我現在面臨的問題是,它什麼都不打印。我已經檢查與螢火蟲的ID4元素,它是這樣的:
<textarea spellcheck="false" class="debug hint" id="id4" style="display: inline;">
<?xml version="1.0"?>
<?xml version="1.0"?>
org.oneandone.ipayment.fraud.wrappers.SimilarIpaymentIdsResponse {
*ipaymentIds => org.oneandone.ipayment.fraud.IpaymentIds {
ipaymentId => [
0 => 80000000000
1 => 2147000165
2 => 2147000180
3 => 2147000130
4 => 2147000190
5 => 2147000192
6 => 2147000197
7 => 2147000144
8 => 2147000151
9 => 2147000198
10 => 2147000001
11 => 2147000170
12 => 2147000185
13 => 2147000179
14 => 2147000182
15 => 2147000183
16 => 2147000186
17 => 2147000193
18 => 2147000199
19 => 2147000201
20 => 2147000202
21 => 2147000204
22 => 2147000187
23 => 2147000218
24 => 2147000222
25 => 2147000301
26 => 2147000433
27 => 2147000434
28 => 2147000438
29 => 2147000461
30 => 2147000120
31 => 2147000462
32 => 2147002088
33 => 2147002672
34 => 2147003278
35 => 2147000229
36 => 2147000232
37 => 2147000326
]
__id => "0.97800600 1383227941"
}
errorcode => 0
additional => "Similar ipaymentIds of 2147000001 retrieved."
__id => "
0.97788900 1383227941"
}</textarea>
如果我嘗試使用outerHTML它打印一切,但XML。這是爲什麼?我如何獲得我需要的信息?它是通過javascript生成的。
什麼是這行提取'asd = textbox.get_text()'?你可以嘗試讓我們知道嗎? – Hemanth
嗨。我無法使用textbox.get_text()(AttributeError的: 'WebElement' 對象沒有屬性 'get_text') 但是,我succesfuly使用textbox.text - >結果是一個空行... 如果我使用ASD = textbox.get_attribute( 「outerHTML」)我得到打印的線,其是這樣的: 但它不包含我試圖獲取的XML – Galactionn