(
driver, theme="default", location="default", max_messages="default"
)
| 893 | |
| 894 | |
| 895 | def set_messenger_theme( |
| 896 | driver, theme="default", location="default", max_messages="default" |
| 897 | ): |
| 898 | if theme == "default": |
| 899 | theme = "future" |
| 900 | if location == "default": |
| 901 | location = "bottom_right" |
| 902 | if getattr(sb_config, "mobile_emulator", None): |
| 903 | location = "top_center" |
| 904 | if max_messages == "default": |
| 905 | max_messages = "8" |
| 906 | |
| 907 | valid_themes = ["flat", "future", "block", "air", "ice"] |
| 908 | if theme not in valid_themes: |
| 909 | raise Exception("Theme: %s is not in %s!" % (theme, valid_themes)) |
| 910 | valid_locations = [ |
| 911 | "top_left", |
| 912 | "top_center", |
| 913 | "top_right", |
| 914 | "bottom_left", |
| 915 | "bottom_center", |
| 916 | "bottom_right", |
| 917 | ] |
| 918 | if location not in valid_locations: |
| 919 | raise Exception( |
| 920 | "Location: %s is not in %s!" % (location, valid_locations) |
| 921 | ) |
| 922 | |
| 923 | if location == "top_left": |
| 924 | messenger_location = "messenger-on-top messenger-on-left" |
| 925 | elif location == "top_center": |
| 926 | messenger_location = "messenger-on-top" |
| 927 | elif location == "top_right": |
| 928 | messenger_location = "messenger-on-top messenger-on-right" |
| 929 | elif location == "bottom_left": |
| 930 | messenger_location = "messenger-on-bottom messenger-on-left" |
| 931 | elif location == "bottom_center": |
| 932 | messenger_location = "messenger-on-bottom" |
| 933 | elif location == "bottom_right": |
| 934 | messenger_location = "messenger-on-bottom messenger-on-right" |
| 935 | |
| 936 | msg_style = ( |
| 937 | "Messenger.options = {'maxMessages': %s, " |
| 938 | "extraClasses: 'messenger-fixed %s', theme: '%s'}" |
| 939 | % (max_messages, messenger_location, theme) |
| 940 | ) |
| 941 | try: |
| 942 | time.sleep(0.015) |
| 943 | execute_script(driver, msg_style) |
| 944 | except Exception: |
| 945 | time.sleep(0.035) |
| 946 | activate_messenger(driver) |
| 947 | time.sleep(0.175) |
| 948 | with suppress(Exception): |
| 949 | execute_script(driver, msg_style) |
| 950 | time.sleep(0.035) |
| 951 | time.sleep(0.055) |
| 952 |
no test coverage detected
searching dependent graphs…