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
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
Here is the code from the module of interest
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
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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 () |
If so what do i need to change?
I'm assuming i need to add some other condition to the following line
1 2 3 |
for r in range ( 2 , rows): username = XLUtils.readData(path, "Sheet1" , r, 1 ) password = XLUtils.readData(path, "Sheet1" , r, 2 ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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.maximize_window() 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 ) |