This is Dart Lessons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, uiautomator2 as u2 | |
def dump_ui(device: str = None): | |
d = u2.connect(device) | |
d.app_start("com.zhiliaoapp.musically") | |
d.wait_activity("com.ss.android.ugc.aweme.splash.SplashActivity", timeout=20) | |
d(description="Discover").wait(timeout=10).click() | |
xml = d.dump_hierarchy() # получаем строку XML | |
with open("ui_dump.xml", "w", encoding="utf-8") as f: | |
f.write(xml) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import unittest | |
def random_with_probability(prob_41): | |
numbers = list(range(1, 100 + 1)) | |
weights = [prob_41 if num == 41 else (1 - prob_41) / (100 - 1) for num in numbers] | |
choice = random.choices(numbers, weights=weights, k=1) | |
return choice[0] |