klarna-incubator / webtraversallibrary

The Web Traversal Library (WTL) is a Python library for abstracting web interactions on top of a base execution layer such as Selenium.
Apache License 2.0
71 stars 7 forks source link

AttributeError: 'NoneType' object has no attribute 'debug' #227

Closed Uncle1Ben closed 2 years ago

Uncle1Ben commented 2 years ago

Hi, I have tried using this library for my project and have run into a strange error right from the start.

After installing the library through pip, I tried to execute code from this documentation: https://webtraversallibrary.readthedocs.io/en/latest/gettingstarted.html

I tried writing the very first example in the page, which would just go to a given url and do nothing.

Unfortunately running this code outputed an error 'AttributeError: 'NoneType' object has no attribute 'debug', which is linked to \webtraversallibrary\workflow.py script, line 85, in init setup_logging(log_dir=output if config.debug.save else None). The error is former in the line 'workflow = wtl.Workflow('

It seems to me that this error is caused by assigning Config in line 69 config: Config = None, and then trying to call the attribute 'debug' on that object. I'm not sure how to fix this error or is it merely my problem somehow and there's no problem with workflow.py script?

I've tried looking for any resources online but except this github project or the documentation (which didn't work for me somehow) I have found nothing else, so I'd be glad if someone could help me resolve this issue.

Full error message:

File "D:\RedditBot\Main.py", line 8, in workflow = wtl.Workflow( File "D:\Python\Python3.9\lib\site-packages\webtraversallibrary\workflow.py", line 85, in init setup_logging(log_dir=output if config.debug.save else None) AttributeError: 'NoneType' object has no attribute 'debug'

Note: I have installed all the required modules which are mentioned in requerements.txt and have tried running the same script from multiple IDE's and got the same error. Python version is 3.9.2.

naslundx commented 2 years ago

Thanks for noticing this! I wonder if something happened where the config object is no longer automatically created when none is passed. I think if you pass config=Config.default() to the workflow it would work fine, but that shouldn't be required. I will take a look.

Uncle1Ben commented 2 years ago

Thanks for your reply! I did what you said and it seems to be working for the most part. Also one of the problems probably was that the web driver wasn't in the same category as the python script. When I put the web driver in the same location the basic script worked and gave this output: Output

It appears to be working but also says that driver check isn't supported, is it because I'm using windows and not for example, linux?

naslundx commented 2 years ago

Correct - IIRC there is no reliable way of obtaining the chrome version on Windows. On linux it's a simple "chrome --version" command.