Q:

Invalid argument error thrown for selenium script

I have a file full of Urls (about some 3000 urls) and the requirement is to get each url invoked in a browser tab and click on each page (just the click is enough on the loaded page), which redirects to a different page. This is all I need to do.
I have written a code for the urls to retrieve one by one and clink on the page (page is designed to click anywhere to land or redirect to a different page). However, while running the code an error is being thrown with "invalid argument". Any thoughts, how can I correct the error ?
Appreciate your support.
    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()

The above code should pull each url from the file on a new browser tab and click. Repeat the same until all the urls in the file are done.

A:

I did something like this
Code
from selenium import webdriver
import time

driver = webdriver.Chrome('driver_location')

f = open("dataFile.txt", 'r')
for line in f:
    driver.get(line)
    link = driver.find_element_by_css_selector("#header > div:nth-child(3) > div > div > div:nth-child(3) > div > a")
    link.click()
    print(driver.current_url)

f.close()

url in dataFile.txt file
http://automationpractice.com/index.php
http://automationpractice.com/index.php
http://automationpractice.com/index.php

output
http://automationpractice.com/index.php?controller=order
http://automationpractice.com/index.php?controller=order
http://automationpractice.com/index.php?controller=order

Hope this helps.

