2012-01-18 20 views
1

セレン機能とWebdriver機能を同じプログラムで使用する方法はありますか?私はスクリーンショットを撮ろうとしていて、そのコマンドでセレンがクラッシュしています。 ".capture_entire_page_screenshot(...)Selenium Webdriver Python side-by-side

答えて

1

SeleniumRC(バージョン1 API)とWebDriver(バージョン2 API)を混ぜてみませんか?二回痛みと快楽のどれも。webdriverをを使用して

、あなたが

import contextlib 
import selenium.webdriver as webdriver 
with contextlib.closing(webdriver.Firefox()) as driver: 
    driver.implicitly_wait(10) 
    driver.get('http://www.google.com') 
    # driver.get_screenshot_as_file('/tmp/google.png') 
    driver.save_screenshot('/tmp/google.png') 
0

を試してみましたが、あなたが見ているものをエラーについて詳しく説明することはできますか?たぶんあなたのコードに問題がある。これは私のために完璧に動作セレニウム1:

from selenium import selenium 
import unittest, time, re 

class IIIAppforloop(unittest.TestCase): 
    def setUp(self): 
     self.verificationErrors = [] 
     self.selenium = selenium("localhost", 4444, "*firefox", "http://www.yahoo.com/") 
     self.selenium.start() 

    def test_i_i_i_appforloop(self): 
     sel = self.selenium 
     sel.open("/") 
     sel.wait_for_page_to_load(60000) 
     sel.capture_entire_page_screenshot(r"C:\picture.png", " ") 


    def tearDown(self): 
     self.selenium.stop() 
     self.assertEqual([], self.verificationErrors) 

if __name__ == "__main__": 
    unittest.main() 
関連する問題