Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python-selenium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Then, install the requirements:

The only direct dependency for this project is [Selenium](https://selenium-python.readthedocs.io/). You should use a Python version of at least 3.10, which is necessary to support [structural pattern matching](https://realpython.com/structural-pattern-matching/).

You'll need a [Firefox Selenium driver](https://selenium-python.readthedocs.io/installation.html#drivers) called `geckodriver` to run the project as-is. Make sure to [download and install](https://github.com/mozilla/geckodriver/releases) it before running the project.
You'll need Firefox installed to run the project as-is. Selenium Manager downloads a matching [`geckodriver`](https://github.com/mozilla/geckodriver/releases) for you the first time you launch a browser, or you can [download and install](https://github.com/mozilla/geckodriver/releases) it yourself.

## Run the Bandcamp Discover Player

To run the music player, install the package, then use the entry-point command from your command line:

```sh
(venv) $ python -m pip install .
(venv) $ bandcamp-player
(venv) $ discover
```

You'll see a text-based user interface that allows you to interact with the music player:
Expand Down
2 changes: 1 addition & 1 deletion python-selenium/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors = [
{ name = "Bartosz Zaczyński", email = "bartosz@realpython.com" },
]
dependencies = [
"selenium",
"selenium==4.50.0",
]
[project.scripts]
discover = "bandcamp.__main__:main"
Expand Down
20 changes: 10 additions & 10 deletions python-selenium/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
attrs==25.2.0
certifi==2025.1.31
h11==0.14.0
idna==3.10
attrs==26.1.0
certifi==2026.7.22
h11==0.16.0
idna==3.20
outcome==1.3.0.post0
pysocks==1.7.1
selenium==4.29.0
selenium==4.50.0
sniffio==1.3.1
sortedcontainers==2.4.0
trio==0.29.0
trio==0.34.0
trio-websocket==0.12.2
typing-extensions==4.12.2
urllib3==2.3.0
websocket-client==1.8.0
wsproto==1.2.0
typing-extensions==4.16.0
urllib3==2.8.0
websocket-client==1.9.2
wsproto==1.3.2
1 change: 0 additions & 1 deletion python-selenium/src/bandcamp/web/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class WebPage:
def __init__(self, driver: WebDriver) -> None:
self._driver = driver
self._driver.set_window_size(*DEFAULT_WINDOW_SIZE)
self._driver.implicitly_wait(5)
self._wait = WebDriverWait(driver, MAX_WAIT_SECONDS)


Expand Down
10 changes: 5 additions & 5 deletions python-selenium/src/bandcamp/web/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DiscoverPageLocator:
DISCOVER_RESULTS = (By.CLASS_NAME, "results-grid")
COOKIE_ACCEPT_NECESSARY = (
By.CSS_SELECTOR,
"#cookie-control-dialog button.g-button.outline",
"div.cookie-control button.g-button.outline",
)


Expand All @@ -16,7 +16,7 @@ class TrackListLocator:

class TrackLocator:
PLAY_BUTTON = (By.CSS_SELECTOR, "button.play-pause-button")
URL = (By.CSS_SELECTOR, "div.meta p a")
ALBUM = (By.CSS_SELECTOR, "div.meta p a strong")
GENRE = (By.CSS_SELECTOR, "div.meta p.genre")
ARTIST = (By.CSS_SELECTOR, "div.meta p a span")
URL = (By.CSS_SELECTOR, "a.stretch-link")
ALBUM = (By.CSS_SELECTOR, "div.title")
GENRE = (By.CSS_SELECTOR, "div.info-pill")
ARTIST = (By.CSS_SELECTOR, "div.attribution-meta")
2 changes: 1 addition & 1 deletion python-selenium/training/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
try:
cookie_accept_button = driver.find_element(
By.CSS_SELECTOR,
"#cookie-control-dialog button.g-button.outline",
"div.cookie-control button.g-button.outline",
)
cookie_accept_button.click()
except NoSuchElementException:
Expand Down
2 changes: 1 addition & 1 deletion python-selenium/training/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
print(tracks[0].text)

track_1 = tracks[0]
album = track_1.find_element(By.CSS_SELECTOR, "div.meta a strong")
album = track_1.find_element(By.CSS_SELECTOR, "div.title")
print(album.text)

driver.quit()
9 changes: 6 additions & 3 deletions python-selenium/training/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
try:
cookie_accept_button = driver.find_element(
By.CSS_SELECTOR,
"#cookie-control-dialog button.g-button.outline",
"div.cookie-control button.g-button.outline",
)
cookie_accept_button.click()
except NoSuchElementException:
pass

pagination_button = driver.find_element(By.ID, "view-more")
wait = WebDriverWait(driver, 10)

pagination_button = wait.until(
EC.element_to_be_clickable((By.ID, "view-more"))
)
pagination_button.click()

wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.ID, "view-more")))

tracks = driver.find_elements(By.CLASS_NAME, "results-grid-item")
Expand Down
166 changes: 95 additions & 71 deletions python-selenium/uv.lock

Large diffs are not rendered by default.

Loading