test_1902506_mp3cut_net.py (1747B)
1 import asyncio 2 3 import pytest 4 from webdriver.error import WebDriverException 5 6 URL = "https://mp3cut.net/it/" 7 PICKER_DROPDOWN_BUTTON_CSS = ".file-picker.el-dropdown button[aria-haspopup=list]" 8 PICKER_FROM_URL_CSS = ".el-dropdown-menu__item.url" 9 AUDIO_FILE_URL = "https://searchfox.org/mozilla-central/source/toolkit/content/tests/widgets/audio.wav" 10 TEMPO_MENU_CSS = ".toolbar:has(.el-radio-button.item.atempo)" 11 TEMPO_BUTTON_CSS = ".el-radio-button.item.atempo, .el-dropdown-menu__item.atempo" 12 UNSUPPORTED_CSS = ".s-atempo.unsupported" 13 SUPPORTED_CSS = ".s-atempo:not(.unsupported) .el-slider.horizontal" 14 15 16 async def open_editor(client): 17 await client.set_prompt_responses(AUDIO_FILE_URL) 18 await client.navigate(URL) 19 client.await_css(PICKER_DROPDOWN_BUTTON_CSS, is_displayed=True).click() 20 for _ in range(10): 21 try: 22 client.await_css(PICKER_FROM_URL_CSS, is_displayed=True).click() 23 break 24 except WebDriverException: # element not interactable 25 await asyncio.sleep(0.5) 26 # The tempo/velocità option may be hidden in a drop-down menu on narrow displays/mobile 27 client.await_css(TEMPO_MENU_CSS, is_displayed=True).click() 28 client.await_css(TEMPO_BUTTON_CSS, is_displayed=True).click() 29 30 31 @pytest.mark.asyncio 32 @pytest.mark.with_interventions 33 async def test_enabled(client): 34 await open_editor(client) 35 assert client.await_css(SUPPORTED_CSS, is_displayed=True) 36 assert not client.find_css(UNSUPPORTED_CSS, is_displayed=True) 37 38 39 @pytest.mark.asyncio 40 @pytest.mark.without_interventions 41 async def test_disabled(client): 42 await open_editor(client) 43 assert client.await_css(UNSUPPORTED_CSS, is_displayed=True) 44 assert not client.find_css(SUPPORTED_CSS, is_displayed=True)