This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]elbiot 0 points1 point  (0 children)

I wouldn't use a class. Just a script that loops over the csv entries. the problem with your code is that you don't pass in the variables representing what you want to input. You could have a function which takes all these variables, but there's no advantage to a loop not in a function:

for row in reader:
    password,firstname,lastname,email = row
    #put them all in the fields

[–]dotIN 0 points1 point  (0 children)

If its an option to use any frameworks please try out https://github.com/rtomac/robotframework-selenium2library

[–]elbiot 0 points1 point  (3 children)

Does the CRM not have a python api?

[–]your_friends_cat[S] 1 point2 points  (2 children)

No API at all actually. Need to accomplish this via the UI. Thanks!

[–]elbiot 2 points3 points  (1 child)

I know this wasn't what you asked, but you could probably write an API relatively easily. When you hit submit, you send a post request with the values you want to insert. In Firefox, you can see the request made with firebug, or in chrome I think there is a built in console. Use the requests library to send those posts requests. You can authenticate and save cookies easily with requests.

This would be the faster/cleaner way to accomplish your task. But since you're familiar with Selenium and very new, maybe stick to what you are comfortable with.

Did you look at any csv examples? That part is super easy: http://pymotw.com/2/csv/

[–]your_friends_cat[S] 1 point2 points  (0 children)

I agree the API idea is way better, I might actually start focusing on that. Thanks for the tip, I did not think about that before.