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