0

Ever since i'v started to load variables from separate file I encountered failure during running python programs with batch files with selenium webdriver.

lets say i have:

project/
│
│── project/
│   ├── schedule.py
│   └── database/
|       └── config.py

inside scheudle.py i got this lines:

from database.config import *

driver = Chrome(options=c_options)
driver.get(url)
password_field = driver.find_element_by_id('password')
password_field.clear()
password_field.send_keys(password)

and inside config.py i got this lines:

password = keyring.get_password(...)

the error i get:

password_field.send_keys(password)
{'text': "".join(keys_to_typing(value)),
for i in range(len(val)):
TypeError: object of type 'NoneType' has no len()

But note this, after i'm opening the python file itself in PyCharm, everything works fine, the batch and all, even if i close PyCharm, its like its loading the vars or something...

I would love to know how to fix this problem, Thanks.

2
  • 2
    Note that you shouldn't use import *, makes everything ambiguous. Consider reading PEP guidelines python.org/dev/peps/pep-0008 Commented Dec 18, 2019 at 16:36
  • How is this related to tag batch-file? Commented Dec 18, 2019 at 20:19

1 Answer 1

1

Have you tried naming the imported config.py:

from database import config
...
password_field.send_keys(config.password)
Sign up to request clarification or add additional context in comments.

1 Comment

maybe your project isn't in your path ? using sys lib: sys.path.append('your/project/path')

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.