Is there any way to use both the selenium functionality and the webdriver functionality in the same program? I am trying to take a screenshot and selenium is crashing at that command ".capture_entire_page_screenshot(...)
I wouldn't try mixing SeleniumRC (the version 1 API) with WebDriver (version 2 API). That would be twice the pain and none of the pleasure.
Using webdriver, have you tried
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')
Can you elaborate on what error you are seeing? Maybe there is something wrong with your code. This works perfectly for me in 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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.