在Selenium Webdriver中,我希望能够使用从Python脚本执行的FireShot获取整页截图。
到目前为止,我有以下代码:
import unittest
import execjs
from execjs import get
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
class PythonOrgSearc(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome('/usr/bin/chromedriver');
def test_login_and_make_payment_on_account(self):
driver = self.driver;
driver.set_window_size(1024,768);
# Log in to My Account
driver.get("https://www.mywebsite.com");
self.assertIn("Sign In", driver.title);
driver.save_screenshot('/Users/username/Documents/Selenium_Test/01a_login.png');
# Enter username
user = driver.find_element_by_id("EmailOrAccountNumber");
user.send_keys("user@me.co.uk");
# Enter password and submit form
password = driver.find_element_by_id("Password");
password.send_keys("password123");
driver.save_screenshot('/Users/username/Documents/Selenium_Test/01b_login_filled.png');
password.send_keys(Keys.RETURN);
# Confirm logged into My Account
self.assertIn("Account Summary", driver.title);
driver.save_screenshot('/Users/username/Documents/Selenium_Test/02a_My_Account.png');
def tearDown(self):
self.driver.close();
if __name__ == "__main__":
unittest.main();
我已经安装了PyExecJS,但不知道如何开始使用FireShot API来替换代码中使用的当前save_screenshot函数。感谢您提供的任何指导或指导。