我用一个旁观灯块,我要点击每个物品和营地;照亮。 每个项目都有一个类别,因此我认为休息会奏效,但我无法选择这些项目。
传真 结构:
<div class="accordionContainer">
<div class="accordion">
<h3>Click This</h3>
<div class="accordionContent" style="display:none">
</div>
<div>
<div class="accordion">
<h3>Click This</h3>
<div class="accordionContent" style="display:none">
</div>
<div>
</div>
粉碎
detailsAccordion = browser.find_elements_by_class_name( accordion )
index = 1
for option in detailsAccordion:
option.click()
try:
element = ui.WebDriverWait(ff, 10).until(lambda driver : driver.find_element_by_xpath("//div[@class= accordion ][" + str(index) + "]/div[@class= accordionContent ]").text != "" )
except:
print "Can t do it"
browser.quit()
index = index + 1
n = nextNumber(n)
browser.save_screenshot( {0}{1}.png .format(imagesPath, n))
option.click()
这造成了以下错误。 我审视了这一错误和现象;人们在互联网选择/环境方面遇到麻烦——我没有代理,无法肯定为什么开始这样做;
[exec] Can t do it
[exec] Traceback (most recent call last):
[exec] File "viewEmployeeUseCase.py", line 82, in <module>
[exec] ff.save_screenshot( {0}{1}.png .format(imagesPath, n))
[exec] File "C:Python26libsite-packagesselenium-2.20.0-py2.6.eggseleniumwebdriverfirefoxwebdriver.py", line 75, in save_screenshot
[exec] png = RemoteWebDriver.execute(self, Command.SCREENSHOT)[ value ]
[exec] File "C:Python26libsite-packagesselenium-2.20.0-py2.6.eggseleniumwebdriver
emotewebdriver.py", line 151, in execute
[exec] response = self.command_executor.execute(driver_command, params)
[exec] File "C:Python26libsite-packagesselenium-2.20.0-py2.6.eggseleniumwebdriver
emote
emote_connection.py", line 280, in execute
[exec] return self._request(url, method=command_info[0], data=data)
[exec] File "C:Python26libsite-packagesselenium-2.20.0-py2.6.eggseleniumwebdriver
emote
emote_connection.py", line 321, in _request
[exec] response = opener.open(request)
[exec] File "C:Python26liburllib2.py", line 391, in open
[exec] response = self._open(req, data)
[exec] File "C:Python26liburllib2.py", line 409, in _open
[exec] _open , req)
[exec] File "C:Python26liburllib2.py", line 369, in _call_chain
[exec] result = func(*args)
[exec] File "C:Python26liburllib2.py", line 1170, in http_open
[exec] return self.do_open(httplib.HTTPConnection, req)
[exec] File "C:Python26liburllib2.py", line 1145, in do_open
[exec] raise URLError(err)
[exec] urllib2.URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
• 做简单的事情;不等待内容去做工件的罚款和整件;我都想到的是:
for option in detailsAccordion:
#print option
option.click()
WebDriverWait(ff, 2)
n = nextNumber(n)
ff.save_screenshot( {0}{1}.png .format(imagesPath, n))
option.click()