tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_1963270_app_kosmi_io.py (2656B)


      1 import pytest
      2 from webdriver.error import NoSuchElementException, StaleElementReferenceException
      3 
      4 URL = "https://app.kosmi.io"
      5 USERNAME_CSS = "input[placeholder='Username or Email']"
      6 PASSWORD_CSS = "input[placeholder='Password']"
      7 LOGIN_BUTTON_CSS = "[type=submit]"
      8 MY_ROOM_TEXT = "My room"
      9 SELECT_MEDIA_CSS = ".kosmi.mediabutton"
     10 HERO_CSS = "button i.linkify"
     11 LOCAL_FILE_CSS = "button i.file.video"
     12 
     13 
     14 async def is_local_file_option_shown(client, credentials, platform):
     15    await client.navigate(URL)
     16    client.await_css(
     17        "button",
     18        condition="elem.innerText.replaceAll(' ', '').includes('Login')",
     19        is_displayed=True,
     20    ).click()
     21    await client.stall(1)
     22    client.await_css(
     23        "button",
     24        condition="elem.innerText.includes('Login with Email')",
     25        is_displayed=True,
     26    ).click()
     27    client.await_css(USERNAME_CSS, is_displayed=True).send_keys(credentials["username"])
     28    client.await_css(PASSWORD_CSS, is_displayed=True).send_keys(credentials["password"])
     29    client.soft_click(client.await_css(LOGIN_BUTTON_CSS, is_displayed=True))
     30    for _ in range(5):
     31        try:
     32            if platform == "android":
     33                await client.apz_click(
     34                    element=client.await_css(
     35                        "div",
     36                        condition="elem.firstChild?.nodeValue?.includes('\\'s room')",
     37                        is_displayed=True,
     38                        timeout=0.5,
     39                    )
     40                )
     41            else:
     42                client.await_css(
     43                    "button",
     44                    condition="elem.firstChild?.nodeValue?.includes('My room')",
     45                    is_displayed=True,
     46                    timeout=0.5,
     47                ).click()
     48            client.await_css(HERO_CSS, is_displayed=True, timeout=1)
     49            break
     50        except (NoSuchElementException, StaleElementReferenceException):
     51            pass
     52    for _ in range(5):
     53        try:
     54            client.soft_click(client.await_css(SELECT_MEDIA_CSS, is_displayed=True))
     55            client.await_css(HERO_CSS, is_displayed=True, timeout=0.5)
     56            break
     57        except NoSuchElementException:
     58            pass
     59    client.await_css(HERO_CSS, is_displayed=True)
     60    return client.find_css(LOCAL_FILE_CSS)
     61 
     62 
     63 @pytest.mark.asyncio
     64 @pytest.mark.with_interventions
     65 async def test_enabled(client, credentials, platform):
     66    assert await is_local_file_option_shown(client, credentials, platform)
     67 
     68 
     69 @pytest.mark.asyncio
     70 @pytest.mark.without_interventions
     71 async def test_disabled(client, credentials, platform):
     72    assert not await is_local_file_option_shown(client, credentials, platform)