【发布时间】:2015-07-16 07:53:29
【问题描述】:
我想在我的armv7板上登录amazons3(使用url:'https://console.aws.amazon.com/iam/home?#security_credential')。我使用了here的phantom2.0.1和selenium2.45.0。
我可以成功打开网站,但是当我在填写用户名和密码后“提交”时,网站跳转到显示“请启用 Cookie 以继续”的错误页面。所以我想知道如何在 selenium 中为 phantomjs 启用 cookie。在我的 ubuntu12.04 中使用合适版本的 phantomjs,我可以成功
我的部分代码如下:
def __init__(self,username,password,login_url,width=1151,height=629):
self.username = username
self.password = password
self.login_url = login_url
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = ( "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) Phantomjs/2.0.1 Safari/534.34" )
self.driver = webdriver.PhantomJS(executable_path='/bin/phantomjs',desired_capabilities=dcap,service_args=['--ssl-protocol=any','--ignore-ssl-errors=true'])
self.driver.set_window_size(width,height)
def _login_system(self):
try:
self.driver.get(self.login_url)
print self.driver.page_source#I can success here
WebDriverWait(self.driver, 30).until(lambda driver : self.driver.find_element_by_id("ap_email")).send_keys(self.username)
WebDriverWait(self.driver, 30).until(lambda driver : self.driver.find_element_by_id("ap_password")).send_keys(self.password)
WebDriverWait(self.driver, 30).until(lambda driver : self.driver.find_element_by_id("signInSubmit-input")).submit()#failed here and showing Please Enable Cookies to Continue
【问题讨论】:
-
PhantomJS 支持 cookie,它们默认是启用的。不确定,为什么这是一个问题。也许那个二进制文件不好。
-
@ArtjomB。感谢您的回答。我尝试在我的 armv7 板和 qemu 上使用 rootfs 编译 phantomjs,但它一直失败,我搜索了这个问题,有人提到了它可能内存不足。您对编译有什么建议吗?非常感谢.make[2]: *** [generated/JSDOMWindow.cpp] 错误 255 make[2]: 离开目录
/phantomjs/src/qt/qtwebkit/Source/WebCore' make[1]: *** [sub-DerivedSources-pri-make_first-ordered] Error 2 make[1]: Leaving directory/phantomjs/src/qt/qtwebkit/Source/WebCore' make: *** [ sub-Source-WebCore-WebCore-pro-make_first-ordered] 错误 2
标签: python cookies selenium-webdriver phantomjs