Python Forum
Invalid argument error thrown.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invalid argument error thrown.
#1
Hello,

While running the following code an error thrown with "invalid argument". Appreciate your thoughts.

with open(dataFile, 'r') as urlFile:
    urlFile.readline()
    for url in urlFile:
        driver = webdriver.Chrome('C:\\chromedriver_win32\\chromedriver.exe')
        driver.get('url', )
        link = driver.find_element_by_xpath("/html/body")
        link.click()
    urlFile.close()
Error is as below :

Traceback (most recent call last):
File "C:/Users/spullabhotla/PycharmProjects/AutomateBoringStuff/Chapter-16-SendingEmail&TextMessages/fetchingEmailMessages.py", line 32, in <module>
driver.get('url', )
File "C:\Users\spullabhotla\Documents\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\spullabhotla\Documents\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\spullabhotla\Documents\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: chrome=76.0.3809.132)
Reply
#2
Line 5: change string 'url' to variable url.
Reply
#3
I have tried without the quotes. and it throws the same error.

Traceback (most recent call last):
  File "C:/Users/spullabhotla/PycharmProjects/AutomateBoringStuff/Chapter-16-SendingEmail&TextMessages/fetchingEmailMessages.py", line 32, in <module>
    driver.get(url, )
  File "C:\Users\spullabhotla\Documents\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\spullabhotla\Documents\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\spullabhotla\Documents\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: chrome=76.0.3809.132)
Reply
#4
Here is the code which opens the url and after loading the page, it will kill the driver. Again it will open another session for next link in the file and it will close the driver once loading is done

 
import selenium.webdriver

with open('dataFile.txt', 'r') as urlFile:
   
    for url in urlFile.readlines():
        print(url)
        driver = selenium.webdriver.Chrome(r"C:\Users\Malathi\Downloads\chromedriver_win32\chromedriver.exe")
        driver.get(url, )
        link = driver.find_element_by_xpath("/html/body")
        link.click()
        driver.quit()
     urlFile.close()
Reply
#5
It worked very well. But it is just not fast enough as I thought. Working well though.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange argument count error rowan_bradley 3 700 Aug-06-2023, 10:58 AM
Last Post: rowan_bradley
  error: invalid command 'egg_info' TimTu 0 948 Jul-27-2023, 07:30 AM
Last Post: TimTu
  Invalid argument: 'images\x08ackground.jpg' CatBall 4 954 Jun-19-2023, 09:28 AM
Last Post: CatBall
  which exception should be thrown for a sequence of the wrong length? Skaperen 1 846 Jan-06-2023, 04:13 AM
Last Post: deanhystad
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 10,915 Dec-26-2022, 08:48 AM
Last Post: ibreeden
  Invalid format specifier Error Led_Zeppelin 2 7,754 Jul-11-2022, 03:55 PM
Last Post: Led_Zeppelin
  Error: _vhstack_dispatcher() takes 1 positional argument but 9 were given alexfrol86 3 5,798 May-09-2022, 12:49 PM
Last Post: deanhystad
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 3,150 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Unexplained Invalid syntax Error cybertooth 5 3,239 Aug-02-2021, 10:05 AM
Last Post: cybertooth
  [split] [Errno 22] Invalid argument Junaid 0 2,279 Jun-12-2021, 06:02 PM
Last Post: Junaid

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020