Apr-20-2019, 01:10 AM
note: i have another forum topic going with the same project. I've whited out a few lines to I can continue to practice until i resolve the other forum issue.
https://python-forum.io/Thread-Permissio...nied-error
In the mean time i have another issue which i'm raising here. Please be patient, i'm trying to learn and have a long long way to go with my development.
I have my code able to successfully look at a spreadsheet with a mix of working and not working username and passwords. The code will successfully add the username and password for the 4 different test cases but then gives the error message
TypeError: object of type 'NoneType' has no len
If so what do i need to change?
I'm assuming i need to add some other condition to the following line
https://python-forum.io/Thread-Permissio...nied-error
In the mean time i have another issue which i'm raising here. Please be patient, i'm trying to learn and have a long long way to go with my development.
I have my code able to successfully look at a spreadsheet with a mix of working and not working username and passwords. The code will successfully add the username and password for the 4 different test cases but then gives the error message
TypeError: object of type 'NoneType' has no len
C:\Python37\python.exe C:/Users/David/PycharmProjects/POM/DataDrivenTestCase.py test is passed test failed test failed test failed Traceback (most recent call last): File "C:/Users/David/PycharmProjects/POM/DataDrivenTestCase.py", line 24, in <module> driver.find_element_by_name("userName").send_keys(username) File "C:\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 478, in send_keys {'text': "".join(keys_to_typing(value)), File "C:\Python37\lib\site-packages\selenium\webdriver\common\utils.py", line 150, in keys_to_typing for i in range(len(val)): TypeError: object of type 'NoneType' has no len()I'm guessing this is because of the loop I have? to it looks at the first 5 rows in my spreadsheet which have conditions and then hits the 6th row which is blank? Would my assumption be right?
If so what do i need to change?
I'm assuming i need to add some other condition to the following line
for r in range(2, rows): username = XLUtils.readData(path, "Sheet1", r, 1) password = XLUtils.readData(path, "Sheet1", r, 2)Here is the code from the module of interest
from selenium import webdriver import unittest import XLUtils profile_path = 'C:/FireFoxProfile' profile = webdriver.FirefoxProfile(profile_path) driver = webdriver.Firefox(firefox_profile=profile_path) driver.implicitly_wait(5) driver.get('http://www.demoaut.com/') driver.maximize_window() [b]path = "C://FireFoxProfile/login1.xlsx"[/b] rows = XLUtils.getRowCount(path, 'Sheet1') for r in range(2, rows): username = XLUtils.readData(path, "Sheet1", r, 1) password = XLUtils.readData(path, "Sheet1", r, 2) driver.find_element_by_name("userName").send_keys(username) driver.find_element_by_name("password").send_keys(password) driver.find_element_by_name("login").click() if driver.title == "Find a Flight: Mercury Tours:": print("test is passed") XLUtils.writeData(path, "Sheet1", r, 3, "test passed") else: print("test failed") XLUtils.writeData(path, "Sheet1", r, 3, "test failed") driver.find_element_by_link_text("Home").click() @classmethod def tearDownClass(cls): cls.driver.quit() if __name__ == '__main__': unittest.main(verbosity=2)