diff --git a/requirements.txt b/requirements.txt index 34fc9cb..303c01c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ pytest==7.1.3 pytest-asyncio==0.20.3 uvicorn==0.20.0 pydantic~=1.10.4 +browserstack-local >= 1.2.3 diff --git a/src/index.py b/src/index.py index 246f9fb..fe46cfb 100644 --- a/src/index.py +++ b/src/index.py @@ -1,20 +1,46 @@ from fastapi import FastAPI from src.dtos.ISayHelloDto import ISayHelloDto - +from selenium import webdriver +import time +from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.options import Options +import os +import json +from selenium import webdriver +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.chrome.options import Options as ChromeOptions +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.by import By +from selenium.common.exceptions import NoSuchElementException +import time app = FastAPI() +BROWSERSTACK_USERNAME = "tranngocminh_AFiWRo" +BROWSERSTACK_ACCESS_KEY = "8anY1yMSZhs7qsHCzLeD" +URL = "https://hub.browserstack.com/wd/hub" + @app.get("/") async def root(): - return {"message": "Hello World"} - - -@app.get("/hello/{name}") -async def say_hello(name: str): - return {"message": f"Hello {name}"} - - -@app.post("/hello") -async def hello_message(dto: ISayHelloDto): - return {"message": f"Hello {dto.message}"} + BROWSERSTACK_USERNAME = BROWSERSTACK_USERNAME + BROWSERSTACK_ACCESS_KEY = BROWSERSTACK_ACCESS_KEY + URL = URL + + bstack_options = { + "os": "OS X", + "osVersion": "Monterey", + "buildName": "browserstack-build-1", + "sessionName": "BStack single python", + "userName": BROWSERSTACK_USERNAME, + "accessKey": BROWSERSTACK_ACCESS_KEY + } + bstack_options["source"] = "python:sample-main:v1.0" + options = ChromeOptions() + options.set_capability('bstack:options', bstack_options) + driver = webdriver.Remote( + command_executor=URL, + options=options) + driver.get("https://www.synthesia.io/features/avatars") + driver.quit() + return {"message": "tôi tên là ngọc"}