2015-05-06 41 views
4

我想在我的armv7板上以amazons3(地址:'https://console.aws.amazon.com/iam/home?#security_credential')登錄。我使用的是來自here和selenium2.45.0的phantom2.0.1。在Phantomjs + selenium中啓用cookie

我可以成功地打開網頁,但是當我做填充的用戶名和密碼,網站跳轉到一個錯誤頁面,顯示「請,啓動cookies來繼續」後,「提交」。所以,我不知道如何啓用phantomjs cookies在selenium.In我與phantomjs合適的版本ubuntu12.04,我能成功的我的代碼

部分低於:

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 
+1

PhantomJS支持cookie,默認情況下它們處於啓用狀態。不知道,爲什麼這是一個問題。也許這個二進制文件不好。 –

+0

@ ArtjomB.Thanks for your answer.I've試圖在我的armv7板和qemu上用rootfs編譯phantomjs,但它一直失敗,我搜索了這個問題,並且有人提到它可能是內存不足。你有什麼編譯建議? make [2]:*** [generated/JSDOMWindow.cpp]錯誤255 make [2]:離開目錄'/ phantomjs/src/qt/qtwebkit/Source/WebCore' make [1]:* ** [子DerivedSources-PRI-make_first有序]錯誤2 化妝[1]:離開目錄'/ phantomjs/SRC/QT/QtWebKit的/來源/ WebCore的」 化妝:*** [子源 - WebCore- WebCore-pro-make_first-ordered]錯誤2 – lulujun21

回答

5

我已經找到了答案, 看來,亞馬遜不接受 「Phantomjs /(。*)」 中的用戶代理

失敗:Mozilla的/ 5.0(Macintosh上,英特爾的Mac OS X)爲AppleWebKit/534.34(KHTML,例如Gecko)Phantomjs /2.0.1 Safari/534.34

確定:Mozilla/5.0(Macintosh;英特爾Mac OS X 10.9; RV:36.0)的Gecko/20100101火狐/ 36.0的WebKit

另外,我想補充 「WebKit的」 在用戶代理的結束,因爲這個問題的 「不確定是不是對象」(https://github.com/detro/ghostdriver/issues/325

更重要的是,我見過的問題「提高BadStatusLine(線)」(喜歡這裏:enter link description here)。並且它可以通過dismatch硒和phantomjs的版本 引起的,所以我用phantomjs1.9.8代替(piksel/phantomjs -raspberrypi在github上)

對於編譯的問題,如果你是編譯在手臂上板,你最好使用swap擴展RAM。

+0

謝謝你解決這個問題!爲亞馬遜工作。 –