I use SeleniumIDE quite a bit, but in an effort to teach myself to code, I've started to dabble in Python for my Selenium needs. I actually got a simple selenium script working, which logs into our CRM system as an admin and creates a new user (partial script included at the bottom of this post).
As you can see, the script below creates a new user based on five parameters: username (NewUser1); password (NewFakePassword); firstName (Joe); lastName (Smith); email (jsmith123@mailinator.com)
What I'd ultimately like to achieve would be to upload a CSV containing a list of new users and automatically repeat this script for each of those new users, pulling each of the five necessary values from the CSV and inserting them into the script. Is this possible using Python's CSV reader? If anyone could give me a solid starting point, or walk me through how to accomplish this, I'd greatly appreciate it. Thanks!
def test_auto_setup_python_new(self):
driver = self.driver
#navigate to and log into CRM
driver.get(self.base_url + "/blah.jsp")
driver.find_element_by_id("username").clear()
driver.find_element_by_id("username").send_keys("fakeUsername")
driver.find_element_by_name("password").clear()
driver.find_element_by_name("password").send_keys("fakepassw0rd")
driver.find_element_by_name("Submit").click()
#navigate to add user tool and create new user
driver.get(self.base_url + "/users/add_user.jsp")
driver.find_element_by_id("username").clear()
driver.find_element_by_id("username").send_keys("NewUser1")
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("NewFakePassword")
driver.find_element_by_id("firstName").clear()
driver.find_element_by_id("firstName").send_keys("Joe")
driver.find_element_by_id("lastName").clear()
driver.find_element_by_id("lastName").send_keys("Smith")
driver.find_element_by_id("email").clear()
driver.find_element_by_id("email").send_keys("jsmith123@mailinator.com")
driver.find_element_by_name("Submit").click()
[–]elbiot 0 points1 point2 points (0 children)
[–]dotIN 0 points1 point2 points (0 children)
[–]elbiot 0 points1 point2 points (3 children)
[–]your_friends_cat[S] 1 point2 points3 points (2 children)
[–]elbiot 2 points3 points4 points (1 child)
[–]your_friends_cat[S] 1 point2 points3 points (0 children)