# Get current statestate = await env.get_state()print(f"Current state: {state}")# Get list of state mutationsmutations = await env.get_state_mutations()print(f"State changes: {mutations}")
If you need full control over the browser configuration, you can set up your own browser instance. The setup depends on whether you’re working with recorded apps or non-recorded apps.
For recorded apps like DoorDash, Uber, etc., you need to use Plato’s proxy configuration to ensure proper state tracking and interaction recording. You can find the complete example in our GitHub repository at custom_browser_environment.py.
Copy
from plato.sync_sdk import SyncPlatofrom playwright.sync_api import sync_playwright# Initialize clientclient = SyncPlato()# Create environment for recorded appenv = client.make_environment( env_id="doordash", # or other recorded app interface_type=None, # Required for custom browser)# Initialize environmentenv.wait_for_ready()env.reset()# Get proxy configurationproxy_config = env.get_proxy_config()# Returns:# {# "server": "https://proxy.plato.so",# "username": "<env_id>",# "password": "<session_id>"# }# Launch browser with proxywith sync_playwright() as p: browser = p.chromium.launch( headless=False, # Set to True for headless mode proxy=proxy_config, args=[ "--ignore-certificate-errors", "--ignore-ssl-errors", "--disable-http2", ], ) page = browser.new_page() # Your automation code here
For non-recorded apps (regular software applications), you can use the public URL directly without proxy configuration:
Copy
from plato.sync_sdk import SyncPlatofrom playwright.sync_api import sync_playwright# Initialize clientclient = SyncPlato()# Create environment for non-recorded appenv = client.make_environment( env_id="espocrm", interface_type=None, # Required for custom browser)# Initialize environmentenv.wait_for_ready()env.reset()# Get public URL instead of proxypublic_url = env.get_public_url()print(f"Public URL: {public_url}")# Launch browser without proxywith sync_playwright() as p: browser = p.chromium.launch( ) page = browser.new_page() # Navigate to the public URL page.goto(public_url) # Your automation code here
You can access your environment through several URLs:
Copy
# Get live view URL (for monitoring)live_url = await env.get_live_view_url()# Get public URLpublic_url = await env.get_public_url()# Get session URLsession_url = await env.get_session_url()