繁体   English   中英

Selenium Webdriver Python并排

[英]Selenium Webdriver Python side-by-side

是否可以在同一程序中同时使用硒功能和WebDriver功能? 我正在尝试截屏,硒在该命令“ .capture_entire_page_screenshot(...)

我不会尝试将SeleniumRC(版本1 API)与WebDriver(版本2 API)混合使用。 那将是痛苦的两倍,而没有乐趣。

使用网络驱动程序,您是否尝试过

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')

您能详细说明遇到的错误吗? 也许您的代码有问题。 在Selenium 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()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM