我想使用 Selenium IDE 在 Chrome 中完成一些简单的任务,然后将代码导出到 python 并在那里执行。但是,当我在 python 中执行导出的代码时,什么也没有发生。
# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class TestIDETest():
def setup_method(self, method):
self.driver = webdriver.Chrome('C:/Users/Jakob/Documents/Python-Selenium/chromedriver.exe')
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_iDETest(self):
self.driver.get("https://www.google.de/")
self.driver.set_window_size(1050, 660)
self.driver.find_element(By.NAME, "q").send_keys("wikipedia")
self.driver.find_element(By.NAME, "q").send_keys(Keys.ENTER)
self.driver.find_element(By.CSS_SELECTOR, ".rc:nth-child(3) .LC20lb").click()
self.driver.find_element(By.ID, "txtSearch").click()
self.driver.find_element(By.ID, "txtSearch").send_keys("delta")
self.driver.find_element(By.ID, "txtSearch").send_keys(Keys.ENTER)
self.driver.find_element(By.LINK_TEXT, "English").click()
element = self.driver.find_element(By.CSS_SELECTOR, ".mw-wiki-logo")
actions = ActionChains(self.driver)
actions.move_to_element(element).perform()
element = self.driver.find_element(By.CSS_SELECTOR, "body")
actions = ActionChains(self.driver)
actions.move_to_element(element, 0, 0).perform()
element = self.driver.find_element(By.CSS_SELECTOR, "#ca-talk > a")
actions = ActionChains(self.driver)
actions.move_to_element(element).perform()
self.driver.close()
当我删除类和方法并只执行它工作的“原始”代码时。所以我不确定如何使用这些方法。提前致谢。
斯蒂芬大帝
相关分类