我正在进行一个自动机器人测试项目,以刮取和测试booking.com网站,我的文件夹结构如下
BotScraper
-bookings
- __init__.py
- booking.py
- constants.py
-main.py
main.py代码
from bookings.booking import Booking
# create instance for Booking class
bot = Booking()
bot.landing_page()
booking.py代码
import bookings.constants as const
from selenium import webdriver
# Inherited webdriver.Chrome(superclass) w.r.t booking class(child class)
class Booking(webdriver.Chrome(r"C:\SeleniumDrivers\chromedriver.exe")):
# constructor for driver path default is mentioned
def __init__(self, driver_path=r"C:\SeleniumDrivers\chromedriver.exe"):
self.driver_path = driver_path
# webdriver.chrome class methods accessible now
super(Booking, self).__init__()
def landing_page(self):
# self. (all methods for webdriver.chrome now accessible)
self.get(const.TARGET_BASE_URL)
常量.py代码
TARGET_BASE_URL = "https://www.booking.com"
When I execute the main.py then the browser is opened but , the code stops execution and returns with error
Traceback (most recent call last):
File "C:/Users/wangu/Desktop/Testing_Practices/Selenium/seBotScraper/main.py", line
1, in <module>
from bookings.booking import Booking
File
"C:\Users\wangu\Desktop\Testing_Practices\Selenium\seBotScraper\bookings\booking.py",
line 7, in <module>
class Booking(webdriver.Chrome(r"C:\SeleniumDrivers\chromedriver.exe")):
File "C:\Python38\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 64,
in __init__
desired_capabilities = options.to_capabilities()
AttributeError: 'dict' object has no attribute 'to_capabilities'
进程已完成,退出代码为1
你知道这个错误的原因和解决方法吗
目前没有回答
相关问题 更多 >
编程相关推荐