我谨允许用户提出意见,并根据这些意见作出一些决定。 如果我这样做的话:
driver.execute_script("prompt( Enter smth , smth )")
我听到了一点,但我不能利用它的价值。 是否有任何办法向用户显示输入箱,并使用该箱的数值?
EDIT:这是我的文字:
from selenium.webdriver import Firefox
if __name__ == "__main__":
driver = Firefox()
driver.execute_script("window.promptResponse=prompt( Enter smth , smth )")
a = driver.execute_script("var win = this.browserbot.getUserWindow(); return win.promptResponse")
print "got back %s" % a
除以下例外:
a = driver.execute_script("var win = this.browserbot.getUserWindow(); return win.promptResponse")
File "c:python26libsite-packagesselenium-2.12.1-py2.6.eggseleniumwebdriver
emotewebdriver.py", line 385, in ex
ecute_script
{ script : script, args :converted_args})[ value ]
File "c:python26libsite-packagesselenium-2.12.1-py2.6.eggseleniumwebdriver
emotewebdriver.py", line 153, in ex
ecute
self.error_handler.check_response(response)
File "c:python26libsite-packagesselenium-2.12.1-py2.6.eggseleniumwebdriver
emoteerrorhandler.py", line 110, in
check_response
if message in value:
TypeError: argument of type NoneType is not iterable
我没有做什么?
EDIT:我试图像预告那样做,这里的产出是:
In [1]: from selenium.webdriver import Firefox
In [2]: f = Firefox()
In [3]: a = f.ex
f.execute f.execute_async_script f.execute_script
In [3]: a = f.execute_script("return prompt( Enter smth , smth )")
In [4]: a
Out[4]: {u text : u Enter smth }
In [5]: a
Out[5]: {u text : u Enter smth }
In [6]: class(a)
File "<ipython-input-6-2d2ff4f61612>", line 1
class(a)
^
SyntaxError: invalid syntax
In [7]: type(a)
Out[7]: dict