看一看下面的代碼:硒可見元素不會被識別爲可見
elem = driver.find_element_by_id(":8")
elem.click()
time.sleep(1)
elem = driver.find_element_by_id("country_residence")
print "elem visible ? = " + str(elem.value_of_css_property('visibility'))
Select(elem).select_by_value("DE")
打印指出,該元素是可見這一刻:
elem visible ? = visible
不過,我得到以下錯誤信息:
selenium.common.exceptions.ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace:
at fxdriver.preconditions.visible (file:///var/folders/0s/j6874rlj63qccjx38ltmwy880000gn/T/tmppJ09Vu/extensions/[email protected]/components/command_processor.js:8791:5)
at DelayedCommand.prototype.checkPreconditions_ (file:///var/folders/0s/j6874rlj63qccjx38ltmwy880000gn/T/tmppJ09Vu/extensions/[email protected]/components/command_processor.js:11438:1)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/0s/j6874rlj63qccjx38ltmwy880000gn/T/tmppJ09Vu/extensions/[email protected]/components/command_processor.js:11455:11)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/0s/j6874rlj63qccjx38ltmwy880000gn/T/tmppJ09Vu/extensions/[email protected]/components/command_processor.js:11460:7)
at DelayedCommand.prototype.execute/< (file:///var/folders/0s/j6874rlj63qccjx38ltmwy880000gn/T/tmppJ09Vu/extensions/[email protected]/components/command_processor.js:11402:5)
這怎麼可能?
行爲是否一致?增加'time.sleep()'間隔是否有助於或改變行爲?你能分享到網站的鏈接,以便我們也可以重現它嗎?謝謝。 – alecxe 2014-09-02 12:24:01
附上html樣本,請見。謝謝。 – 2014-09-02 13:52:40