1

I am a beginner in automation field.I have a CSV file with 50 rows each row contains urls.I'm trying to capture only specific rows.

csv file 1.www.google.com 2.www.facebook.com

import csv
from selenium import webdriver
chrome_path=(.......notepad++\chromedriver.exe')
driver=webdriver.Chrome(chrome_path)
driver.implicitly_wait(30)
driver.maximize_window()
with open('list.csv') as fb:
    reader=csv.reader(fb)
    rows=[r for r in reader]
driver.get(rows[1])
driver.quit()

error: selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: 'url' must be a string

1 Answer 1

1

rows[1] is going to be a row, presumably corresponding to the second row of your CSV file.

I imagine your error message is coming from the call to driver.get, which is telling you it wants a string, not a row of strings. So I'd try grabbing whichever field in the row has the URL. I'm not sure how you're describing your CSV, but if it look like this:

1, google.com
2, facebook.com

then it should probably look something like this:

driver.get(rows[1][1])

Or, more readably,

number, url = rows[1]
driver.get(url)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.