Basic navigation
Opening pages
Use theget() method to navigate to a URL:
Opening new tabs
Opening new windows
When you use
new_window=True, it automatically implies new_tab=True.Managing tabs
Getting current tabs
Iterating over tabs
Closing tabs
Browser history
Navigate back and forward
Reload page
Getting page information
Current URL
Page source
Get the current HTML content:Extract all URLs
Waiting strategies
Simple wait
Wait for element
Bothselect() and find() have built-in waiting:
Wait for specific element
Usewait_for() for explicit waiting:
Awaiting the tab
Callingawait tab is important for synchronization:
The
await tab pattern updates the target URL and allows the script to “breathe”, which helps prevent race conditions.