-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathmain.py
More file actions
24 lines (16 loc) · 916 Bytes
/
Copy pathmain.py
File metadata and controls
24 lines (16 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
# date: 2019.11.07
# https://stackoverflow.com/questions/58748338/fill-textarea-with-the-bb-code-in-selenium-python/58748608
import selenium.webdriver
driver = selenium.webdriver.Firefox()
driver.get('https://stackoverflow.com/questions/58748338/fill-textarea-with-the-bb-code-in-selenium-python/58748608')
messageBox = driver.find_element_by_id('wmd-input')
# needs `\` at the end of lines to create one line in JavaScript`
bb_code = '''[B][FONT=Trebuchet MS][SIZE=7]Meteor[/SIZE][/FONT][/B]\
[COLOR=#000000][FONT=Verdana][I][B][SIZE=4]n: [/B][/I][/FONT]\
[S][B][FONT=Verdana]ki[/SIZE][/FONT][/B][/S][/COLOR]\
[URL='https:///coral-lps-6/']\
[FONT=Impact][SIZE=7][COLOR=#F41600][U]CLICK HERE TO BUY![/U][/COLOR][/SIZE][/FONT][/URL]'''
js = 'arguments[0].innerHTML = "{}"'.format(bb_code) # needs `" "` because `[URL]` already use `' '`
print(js)
driver.execute_script(js, messageBox)