答案 0 :(得分:1)
由于find_element_by_class_name
函数属于webdriver.driver
而不是webdriver
而引发错误。请注意,这段代码将打开两个浏览器窗口,而不是一个,因为:
“基于selenium框架的python Web自动化库”
如果您查看来源,则可以看到:
self.driver = webdriver.Chrome(executable_path=driverpath , chrome_options=options)
这意味着您将在这两行中打开两个标签:
driver = webdriver.Chrome(executable_path= r'C:/Users/ryans/OneDrive/Desktop/Briefcase/Python Scripts/chromedriver.exe')
web = Browser()
您实际上并不需要。可以通过以下方式解决:
import requests
import selenium
from selenium import webdriver
from bs4 import BeautifulSoup
from webbot import Browser
web = Browser()
url = 'https://web_site'
web.go_to(url)
# 1st validation
web.type('email' , into='username')
web.click('Continue')
# 2nd validation
web.type('email' , into='username')
web.click('Next')
# password
web.type('pass' , into='password')
web.click('Next')
# Now you are logged in!!
url = 'https://web_page'
web.go_to(url)
# upload CSV Source File:
WebElement = web.driver.find_element_by_class_name('ignore-inline-attach')
web.driver.sendKeys("C:/my_path/test.csv");
# Close browser.
web.close_current_tag()
很高兴为您提供帮助:)