Getting Started with donew
Installation
- Install the package using pip:
pip install donew
- Install required browsers:
donew-install-browsers
Basic Usage
Here’s a simple example to get started with donew:
import asyncio
from donew import DO
async def main():
# Start web navigation
#pass playwright options to the browser
browser = await DO.Browse(headless=True, channel="chrome")
try:
# Analyze page content
content = await browser.text()
print("Page content:", content)
# Get all interactive elements with their context
elements = browser.elements()
# Smart element detection
input_fields = {
elem.element_label or elem.attributes.get("name", ""): id
for id, elem in elements.items()
if elem.element_type == "input"
and elem.attributes.get("type") in ["text", "email"]
}
# Interact with elements
for label, element_id in input_fields.items():
await browser.type(element_id, f"test_{label}")
finally:
await browser.close()
if __name__ == "__main__":
asyncio.run(main())
Next Steps
- Read about Design Principles to understand donew’s capabilities
- Check out more complex Examples
Development Setup
If you’re contributing to donew or want to set up a development environment:
- Clone the repository:
git clone https://github.com/DONEWio/Do.git
cd Do
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e ".[dev]"
- Install Playwright browsers:
donew-install-browsers
Troubleshooting
Common Issues
-
Browser Installation Failed
- Make sure you have sufficient permissions
- Try running
donew-install-browsers
with sudo/admin privileges
-
Connection Errors
- Check your internet connection
- Verify the URL is accessible
- Ensure you’re not being blocked by the target website
-
Element Not Found
- Use
browser.elements()
to list all available elements - Check if the element is in an iframe
- Ensure the element is visible and not dynamically loaded
- Use
For more help, visit our GitHub Issues page.