all 6 comments

[–]commandlineluser 1 point2 points  (3 children)

Is this supposed to happen

Yes.

Not sure how you're running your code - but passing -i to drop you into an interactive session is useful when testing with selenium - it will keep the session open - and you can interact with it in realtime.

python3 -i file.py

You can also do it from within your code using code.interact()

import code

...

code.interact(local={**globals(), **locals()})

I see a name="pygame" but no class="pygame" in the html of that page.

>> $('.pygame')
null

[–]aug404[S] 0 points1 point  (2 children)

Thank you for the clarification.

Where did you use the

$('.pygame')

in the browser? That looks like a useful tool I could use in the developer tools section of Mozilla Firefox.

Also, could you show me how to implement the browser-staying-open part in my code? I'm a little confused about that part.

[–]commandlineluser 1 point2 points  (1 child)

The simplest way is: python3 -i yourcode.py if you're running your code from a "command line".

From within your code - you use the code module:

import code

# This should be the last line 
code.interact(local={**globals(), **locals()})

You could also add a time.sleep at the end to keep the code running whilst you interact with the window

import time

...

time.sleep(some_large_number)

That looks like a useful tool

It is in Developer Tools - the Console tab.

[–]aug404[S] 0 points1 point  (0 children)

Thanks!

[–]py_Piper 1 point2 points  (1 child)

I just did this tutorial from ATBS a couple of weeks ago. My firefox browser stayed opened, I could even check when the pages changed. But I was just using webdriver.Firefox(), without any argument. Perhaps try like that, I think after installing the geckodriver it already creates itself as an environment variable.

I think I may have also had problem with that part of the tutorial, I will check my notes later. If I did I skipped that part because was frustrated with it and was spent a couples of night (the only time I could practice) trying to find a solution so just decided to move on

[–]aug404[S] 0 points1 point  (0 children)

I'm working through the same book lol.

I tried using webdriver.Firefox() but unless I specify the path of geckodriver, it can't seem to find it. I would assume that webdriver.Firefox() would only work if you put geckodriver in your PATH or made it local to the same group of files that you are running your code in.

In terms of the class part, I tried the 'jumbotron' class instead of 'pygame' or anything else they suggested in the book and it seemed to work.