[英]selenium.common.exceptions.InvalidArgumentException: Message: invalid argument error invoking get() using Selenium Webdriver through Python
I am making a GUI that asks for a search, goes to Ebay and finds the average price for that search.我正在制作一个要求搜索的 GUI,转到 Ebay 并找到该搜索的平均价格。 But I can't get it to open Selenium.
但我无法打开 Selenium。 But just cannot find an answer.
但就是找不到答案。 What am I supposed to do?
我应该做些什么? Here is my error:
这是我的错误:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\tkinter\__init__.py", line 1885, in __call__
return self.func(*args)
File "C:\Users\Jay\AppData\Roaming\Python\Python39\site-packages\appJar\appjar.py", line 3781, in <lambda>
return lambda *args: funcName()
File "C:\Users\Jay\Downloads\ebaything\ebay thing.py", line 25, in search
driver.get("ebay.com")
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
(Session info: headless chrome=87.0.4280.88)
And here is my code:这是我的代码:
from appJar import gui
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from time import sleep
def main():
app = gui("Search, And Find The Average!")
PATH = "chromedriver.exe"
options = Options()
options.headless = True
driver = webdriver.Chrome(PATH, options=options)
def close():
app.stop()
def search():
Search = app.getEntry("search")
if Search == '':
app.infoBox("Invalid", "Invalid Search")
else:
driver.get("ebay.com")
driver.find_element_by_xpath('//*[@id="gh-ac"]').send_keys(search)
try:
driver.find_element_by_class('s-item__link')
except:
app.infoBox("Invalid", "There Are No Items Matching Your Search.")
def info():
app.infoBox("InfoBox", "If It Does Not Work Try Reading The FAQ.")
app.addEntry("search")
app.setEntryDefault("search", "Put Your Search Here!")
app.addButton("Close", close)
app.addButton("Search", search)
app.addButton("Info", info)
app.go()
if __name__ == '__main__':
main()
If you need anymore information please leave a comment.如果您需要更多信息,请发表评论。
This error message...此错误消息...
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\tkinter\__init__.py", line 1885, in __call__
.
File "C:\Users\Jay\Downloads\ebaything\ebay thing.py", line 25, in search
driver.get("ebay.com")
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
.
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
(Session info: headless chrome=87.0.4280.88)
...implies that there was an error in the __init__
while executing the line: ...意味着执行该行时
__init__
中存在错误:
driver.get("ebay.com")
Instead of passing the partial domain name ebay.com
you need to pass the complete url ie https://www.ebay.com/
.而不是传递部分域名
ebay.com
您需要传递完整的url即https://www.ebay.com/
。
Additionally you may also like to pass the absolute path of the ChromeDriver through the Key executable_path
.此外,您可能还希望通过Key
executable_path
传递ChromeDriver的绝对路径。 So the effective code block will be:所以有效的代码块将是:
def main():
app = gui("Search, And Find The Average!")
PATH = r'C:\path\to\chromedriver.exe'
options = Options()
options.headless = True
driver = webdriver.Chrome(executable_path=PATH, options=options)
and later然后
driver.get("https://www.ebay.com/")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.