from playwright.sync_api import sync_playwright

USER="ballbox"
PWD="Vendinges2ya##"
with sync_playwright() as pw:
    browser=pw.chromium.launch(headless=True)
    page=browser.new_page(viewport={"width":1400,"height":1200})
    page.goto("https://os.ourvend.com/Account/Login", wait_until="domcontentloaded")
    page.fill('#userName', USER)
    page.fill('#passWord', PWD)
    page.click('text=Login') if page.locator('text=Login').count() else None
    try:
        page.locator('#btnLogin').click(timeout=1000)
    except:
        pass
    try:
        page.evaluate('UserLogin()')
    except Exception:
        pass
    page.wait_for_load_state('networkidle', timeout=30000)
    print('URL', page.url)
    print(page.title())
    page.screenshot(path='/home/sebas/work/reports/ourvend-cloud-map/screens/pass1-status.png', full_page=True)
    print(page.locator('body').inner_text()[:4000])
    browser.close()
