gpt4 book ai didi

python - 我在使用 Selenium 时不断收到 "name"错误。我究竟做错了什么?

转载 作者:太空宇宙 更新时间:2023-11-03 15:53:21 24 4
gpt4 key购买 nike

我做错了什么?我不断收到此错误:

============== RESTART: C:\Users\Redacted\Desktop\Autonav_1.py ==============
E ====================================================================== ERROR: test_autonav_1 (main.Autonav_1) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Redacted\Desktop\Autonav_1.py", line 8, in setUp self.selenium = selenium("localhost", 4444, "*firefox", "Redacted") NameError: name 'selenium' is not defined

Ran 1 test in 0.003s
FAILED (errors=1)


代码:

# -*- coding: utf-8 -*-
from selenium import webdriver
import unittest, time, re

class Autonav_1(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*firefox" "redacted")
self.selenium.start()


def test_autonav_1(self):
sel = self.selenium
sel.open("/hub/login.php")
sel.type("id=Email", "redacted")
sel.type("id=Password", "redacted")
sel.click("id=Login")
sel.wait_for_page_to_load("30000")
sel.click("link=Internet Retailing")
sel.wait_for_page_to_load("30000")
sel.click("id=redacted")
sel.click("id=redacted")
sel.wait_for_page_to_load("30000")

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

if __name__ == "__main__":
unittest.main()

最佳答案

selenium 是库。您需要使用webdriver

def setUp(self):
self.driver = webdriver.Firefox("localhost", 4444, "*firefox" "redacted")

def test_autonav_1(self):
driver = self.driver

关于python - 我在使用 Selenium 时不断收到 "name"错误。我究竟做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41039908/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com