added getting current balance via xpath, not idea

This commit is contained in:
jethro 2026-05-13 16:01:14 +12:00
parent b743ea6fbd
commit 6177fb351f

View file

@ -6,16 +6,23 @@ from dotenv import load_dotenv
load_dotenv()
def run(playwright: Playwright):
chromium = playwright.chromium # or "firefox" or "webkit".
browser = chromium.launch()
firefox = playwright.firefox # or "firefox" or "webkit".
browser = firefox.launch(headless=False)
page = browser.new_page()
response = page.goto(os.getenv("URL"))
page.fill("input#ctl00_ContentPlaceHolder1_txtLoginID", os.getenv("USERNAME"))
page.fill("input#ctl00_ContentPlaceHolder1_txtPassword", os.getenv("PASSWORD"))
page.click("input#ctl00_ContentPlaceHolder1_btnLogin")
#
print(page.content())
html_content = page.content()
with open('result.html', 'w', encoding='utf-8') as f:
f.write(html_content)
current_balance = page.locator("xpath=/html/body/form/div[3]/div[3]/div[2]/div[3]/div[5]/span[2]").inner_text()
print(current_balance)
browser.close()
#xpath = /html/body/form/div[3]/div[3]/div[2]/div[3]/div[5]/span[2]
with sync_playwright() as playwright:
run(playwright)