import pyautogui
import time
def press_key(key: str, time: int):
"""
key: Клавиша
time: Время зажатия
"""
amount_of_clicks = time // 0.03
pyautogui.press(keys=key, presses=int(amount_of_clicks), interval=0.03)
time.sleep(5)
with pyautogui.hold('ctrl'):
press_key("d", 5)
time.sleep(0.5)
press_key("a", 5)
#Начать тест
browser.find_element(By.XPATH, '//*[@id="wpProQuiz_74"]/div[4]/div/input')
for card in browser.find_elements(By.CLASS_NAME, "wpProQuiz_questionListItem")
for checkbox in card.find_elements(By.CLASS_NAME, "wpProQuiz_questionInput")
#логика по выбору флага если нужна
#Проверить
card.find_element(By.CLASS_NAME, "wpProQuiz_QuestionButton")[1].click()
#Далее
card.find_element(By.CLASS_NAME, "wpProQuiz_QuestionButton")[2].click()
for element in driver.find_elements(By.CLASS_NAME, "your_class"):
if element.value_of_css_property("color") == "red":
element.click()
selenium.common.exceptions.NoSuchElementException
from selenium.common.exceptions import NoSuchElementException
try:
element = driver.find_element(By.CLASS_NAME, class_name)
print(element.text)
except NoSuchElementException:
print('Элемент не найден')
def get_accounts_btn(accounts: list) -> InlineKeyboardMarkup:
buttons_list = []
for account in accounts:
if account['bot_is_active'] == 1:
active = ' '
else:
active = ' '
buttons_list.append([
InlineKeyboardButton(
str('Войти как: {0} {1}'.format(account['account_id'], active)),
callback_data='num_{0}'.format(account['account_id']))
])
kb = InlineKeyboardMarkup(inline_keyboard=buttons_list)
return kb
async def get_list_accounts(message: types.Message):
user_id = message.from_user.id
...
accounts = await commands.get_account_id_bot_is_active(user_id)
if accounts:
await message.answer('Выбери аккаунт для входа', reply_markup=get_accounts_btn(accounts))
else:
await message.answer('Аккаунтов не найдено')