forked from cory/tildefriends
Automated enough with selenium to be able to create a Tilde Friends account, create an SSB identity, and post a first message. I'm still confused on some things, but this is progress, and I fixed a longstanding issue creating the first identity.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4377 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
58
tools/autotest.py
Normal file
58
tools/autotest.py
Normal file
@ -0,0 +1,58 @@
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
for path in ('out/selenium.sqlite', 'out/selenium.sqlite-shm', 'out/selenium.sqlite-wal'):
|
||||
try:
|
||||
os.unlink(path)
|
||||
except:
|
||||
pass
|
||||
tf = subprocess.Popen(['out/debug/tildefriends', 'run', '-d', 'out/selenium.sqlite', '-b', '0', '-p', '8888'])
|
||||
|
||||
try:
|
||||
options = webdriver.FirefoxOptions()
|
||||
#options.add_argument('--headless')
|
||||
driver = webdriver.Firefox(options = options)
|
||||
driver.get('http://localhost:8888')
|
||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'login').click()
|
||||
driver.find_element(By.ID, 'register').click()
|
||||
driver.find_element(By.ID, 'name').send_keys('test_user')
|
||||
driver.find_element(By.ID, 'password').send_keys('test_password')
|
||||
driver.find_element(By.ID, 'confirm').send_keys('test_password')
|
||||
driver.find_element(By.ID, 'loginButton').click()
|
||||
|
||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
||||
WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'ssb')))
|
||||
driver.find_element(By.LINK_TEXT, 'ssb').click()
|
||||
driver.switch_to.default_content()
|
||||
|
||||
WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
||||
WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app')))
|
||||
tf_app = driver.find_element(By.TAG_NAME, 'tf-app').shadow_root
|
||||
WebDriverWait(driver, 30).until(expected_conditions.element_to_be_clickable(tf_app.find_element(By.ID, 'create_identity')))
|
||||
tf_app.find_element(By.ID, 'create_identity').click()
|
||||
alert = WebDriverWait(driver, 30).until(expected_conditions.alert_is_present())
|
||||
alert.accept()
|
||||
|
||||
driver.implicitly_wait(3)
|
||||
#tf_app = driver.find_element(By.TAG_NAME, 'tf-app').shadow_root
|
||||
#WebDriverWait(driver, 30).until(expected_conditions.visibility_of(tf_app.find_element(By.ID, 'tf-tab-news')))
|
||||
tf_tab_news = tf_app.find_element(By.ID, 'tf-tab-news').shadow_root
|
||||
tf_tab_news.find_element(By.ID, 'tf-compose').shadow_root.find_element(By.ID, 'edit').send_keys('Hello, world!')
|
||||
tf_tab_news.find_element(By.ID, 'tf-compose').shadow_root.find_element(By.ID, 'submit').click()
|
||||
|
||||
driver.switch_to.default_content()
|
||||
driver.find_element(By.ID, 'allow').click()
|
||||
|
||||
print('SUCCESS.')
|
||||
finally:
|
||||
driver.close()
|
||||
driver.quit()
|
||||
|
||||
tf.terminate()
|
Reference in New Issue
Block a user