forked from cory/tildefriends
test: Make -t auto a bit more resilient by hoisting all the retries into one place that makes sense to me.
This commit is contained in:
parent
c565b2a31f
commit
4b4fd0735b
@ -9,14 +9,65 @@ if sys.platform == 'haiku1':
|
|||||||
print('Automation tests are disabled on Haiku.')
|
print('Automation tests are disabled on Haiku.')
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
import selenium
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.firefox.service import Service
|
from selenium.webdriver.firefox.service import Service
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support import expected_conditions
|
from selenium.webdriver.support import expected_conditions
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
|
||||||
def exists_in_shadow_root(shadow_root, by, value):
|
def select(driver, path, action = None):
|
||||||
return lambda driver: shadow_root.find_element(by, value)
|
start_time = time.time()
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
driver.switch_to.default_content()
|
||||||
|
context = driver
|
||||||
|
for node in path:
|
||||||
|
if node[0] == 'tag':
|
||||||
|
context = context.find_element(By.TAG_NAME, node[1])
|
||||||
|
elif node[0] == 'id':
|
||||||
|
context = context.find_element(By.ID, node[1])
|
||||||
|
elif node[0] == 'xpath':
|
||||||
|
context = context.find_element(By.XPATH, node[1])
|
||||||
|
elif node[0] == 'link_text':
|
||||||
|
context = context.find_element(By.LINK_TEXT, node[1])
|
||||||
|
elif node[0] == 'class_name':
|
||||||
|
context = context.find_element(By.CLASS_NAME, node[1])
|
||||||
|
elif node[0] == 'shadow_root':
|
||||||
|
context = context.shadow_root
|
||||||
|
elif node[0] == 'frame':
|
||||||
|
driver.switch_to.frame(context)
|
||||||
|
context = driver
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f'Unexpected path node: {node}.')
|
||||||
|
if action is not None:
|
||||||
|
if action[0] == 'click':
|
||||||
|
context.click()
|
||||||
|
elif action[0] == 'send_keys':
|
||||||
|
context.send_keys(action[1])
|
||||||
|
elif action[0] == 'clear':
|
||||||
|
context.clear()
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f'Unexpected action: {action}.')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return context
|
||||||
|
except selenium.common.exceptions.NoSuchElementException:
|
||||||
|
if time.time() - start_time < 5.0:
|
||||||
|
time.sleep(0.1)
|
||||||
|
pass
|
||||||
|
except selenium.common.exceptions.NoSuchShadowRootException:
|
||||||
|
if time.time() - start_time < 5.0:
|
||||||
|
time.sleep(0.1)
|
||||||
|
pass
|
||||||
|
except selenium.common.exceptions.StaleElementReferenceException:
|
||||||
|
if time.time() - start_time < 5.0:
|
||||||
|
time.sleep(0.1)
|
||||||
|
pass
|
||||||
|
except selenium.common.exceptions.WebDriverException:
|
||||||
|
if time.time() - start_time < 5.0:
|
||||||
|
time.sleep(0.1)
|
||||||
|
pass
|
||||||
|
|
||||||
success = False
|
success = False
|
||||||
try:
|
try:
|
||||||
@ -27,290 +78,176 @@ try:
|
|||||||
wait = WebDriverWait(driver, 10)
|
wait = WebDriverWait(driver, 10)
|
||||||
|
|
||||||
driver.get('http://localhost:8888')
|
driver.get('http://localhost:8888')
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'login').click()
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('link_text', 'login')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'register_label').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'register_label')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('adminuser')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'adminuser'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('admin_password')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'admin_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('admin_password')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'confirm')], ('send_keys', 'admin_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('id', 'document'), ('frame',), ('link_text', 'identity')])
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'identity')))
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
|
|
||||||
driver.get('http://localhost:8888/~core/admin/')
|
driver.get('http://localhost:8888/~core/admin/')
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('id', 'document'), ('frame',), ('id', 'gs_room_name')], ('send_keys', 'test room'))
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
select(driver, [('id', 'document'), ('frame',), ('xpath', '//*[@id="gs_room_name"]/following-sibling::button')], ('click',))
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'gs_room_name'))).send_keys('test room')
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//*[@id="gs_room_name"]/following-sibling::button'))).click()
|
|
||||||
driver.switch_to.alert.accept()
|
driver.switch_to.alert.accept()
|
||||||
driver.switch_to.default_content()
|
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click()
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'identity')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click()
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'logout')], ('click',))
|
||||||
|
|
||||||
driver.get('http://localhost:8888')
|
driver.get('http://localhost:8888')
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'login').click()
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('link_text', 'login')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'register_label').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'register_label')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('test_password')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'confirm')], ('send_keys', 'test_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
|
select(driver, [('id', 'document')])
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'create_identity')], ('click',))
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'create_identity').click()
|
|
||||||
wait.until(expected_conditions.alert_is_present()).accept()
|
wait.until(expected_conditions.alert_is_present()).accept()
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'identity')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'id_dropdown'), ('xpath', '//button[position()=2]')], ('click',))
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
select(driver, [('id', 'document'), ('frame',), ('tag', 'tf-app'), ('shadow_root',), ('id', 'tf-tab-news'), ('shadow_root',), ('class_name', 'tf-profile'), ('shadow_root',), ('id', 'edit_profile')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click()
|
select(driver, [('id', 'document'), ('frame',), ('tag', 'tf-app'), ('shadow_root',), ('id', 'tf-tab-news'), ('shadow_root',), ('class_name', 'tf-profile'), ('shadow_root',), ('id', 'name')], ('send_keys', 'user'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'id_dropdown').find_element(By.XPATH, '//button[position()=2]').click()
|
select(driver, [('id', 'document'), ('frame',), ('tag', 'tf-app'), ('shadow_root',), ('id', 'tf-tab-news'), ('shadow_root',), ('class_name', 'tf-profile'), ('shadow_root',), ('id', 'save_profile')], ('click',))
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
select(driver, [('xpath', '//button[text()="✅ Allow"]')], ('click',))
|
||||||
# NoSuchShadowRootException
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
tf_app = wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
wait.until(exists_in_shadow_root(wait.until(exists_in_shadow_root(tf_app, By.ID, 'tf-tab-news')).shadow_root, By.CLASS_NAME, 'tf-profile')).shadow_root.find_element(By.ID, 'edit_profile').click()
|
|
||||||
wait.until(exists_in_shadow_root(wait.until(exists_in_shadow_root(tf_app, By.ID, 'tf-tab-news')).shadow_root, By.CLASS_NAME, 'tf-profile')).shadow_root.find_element(By.ID, 'name').send_keys('user')
|
|
||||||
wait.until(exists_in_shadow_root(wait.until(exists_in_shadow_root(tf_app, By.ID, 'tf-tab-news')).shadow_root, By.CLASS_NAME, 'tf-profile')).shadow_root.find_element(By.ID, 'save_profile').click()
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//button[text()="✅ Allow"]'))).click()
|
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
driver.get('http://localhost:8888/~testuser/test/')
|
driver.get('http://localhost:8888/~testuser/test/')
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('id', 'document')])
|
||||||
while True:
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'close_error')], ('click',))
|
||||||
try:
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('link_text', 'edit')], ('click',))
|
||||||
wait.until(exists_in_shadow_root(driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root, By.ID, 'close_error')).click()
|
select(driver, [('id', 'editor'), ('class_name', 'cm-content')], ('click',))
|
||||||
break
|
select(driver, [('id', 'editor'), ('class_name', 'cm-content')], ('send_keys', 'app.setDocument(\n\t"<div id=\'test-div\'>Hello, world!</div>"\n);'))
|
||||||
except:
|
select(driver, [('id', 'save')], ('click',))
|
||||||
pass
|
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
select(driver, [('id', 'document'), ('frame',), ('id', 'test-div')])
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'edit').click()
|
|
||||||
editor = driver.find_element(By.ID, 'editor').find_element(By.CLASS_NAME, 'cm-content')
|
|
||||||
editor.click()
|
|
||||||
editor.send_keys('app.setDocument(\n\t"<div id=\'test-div\'>Hello, world!</div>"\n);');
|
|
||||||
driver.find_element(By.ID, 'save').click()
|
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'test-div')))
|
|
||||||
|
|
||||||
size = driver.get_window_size()
|
size = driver.get_window_size()
|
||||||
driver.set_window_size(1200, 540)
|
driver.set_window_size(1200, 540)
|
||||||
driver.save_screenshot('out/screenshot0.png')
|
driver.save_screenshot('out/screenshot0.png')
|
||||||
driver.set_window_size(size['width'], size['height'])
|
driver.set_window_size(size['width'], size['height'])
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
select(driver, [('id', 'editor'), ('class_name', 'cm-content')], ('click',))
|
||||||
editor = driver.find_element(By.ID, 'editor').find_element(By.CLASS_NAME, 'cm-content')
|
select(driver, [('id', 'editor'), ('class_name', 'cm-content')], ('clear',))
|
||||||
editor.click()
|
select(driver, [('id', 'editor'), ('class_name', 'cm-content')], ('send_keys', 'app.setDocument("<div id=\'test-div2\'>Hello, world, again!</div>")'))
|
||||||
editor.clear()
|
select(driver, [('id', 'save')], ('click',))
|
||||||
editor.send_keys('app.setDocument("<div id=\'test-div2\'>Hello, world, again!</div>")');
|
select(driver, [('id', 'document'), ('frame',), ('id', 'test-div2')])
|
||||||
driver.find_element(By.ID, 'save').click()
|
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('id', 'delete')], ('click',))
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'test-div2')))
|
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
driver.find_element(By.ID, 'delete').click()
|
|
||||||
wait.until(expected_conditions.alert_is_present()).accept()
|
wait.until(expected_conditions.alert_is_present()).accept()
|
||||||
wait.until(expected_conditions.alert_is_present()).dismiss()
|
wait.until(expected_conditions.alert_is_present()).dismiss()
|
||||||
driver.get('http://localhost:8888/~testuser/test/')
|
driver.get('http://localhost:8888/~testuser/test/')
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
|
||||||
while True:
|
select(driver, [('id', 'document')])
|
||||||
try:
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'close_error')], ('click',))
|
||||||
wait.until(exists_in_shadow_root(driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root, By.ID, 'close_error')).click()
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('link_text', 'edit')], ('click',))
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'edit').click()
|
|
||||||
|
|
||||||
driver.get('http://localhost:8888')
|
driver.get('http://localhost:8888')
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('id', 'document'), ('frame',), ('link_text', 'identity')])
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'identity')))
|
|
||||||
|
|
||||||
size = driver.get_window_size()
|
size = driver.get_window_size()
|
||||||
driver.set_window_size(540, 1200)
|
driver.set_window_size(540, 1200)
|
||||||
driver.save_screenshot('out/screenshot1.png')
|
driver.save_screenshot('out/screenshot1.png')
|
||||||
driver.set_window_size(size['width'], size['height'])
|
driver.set_window_size(size['width'], size['height'])
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'identity'))).click()
|
select(driver, [('id', 'document'), ('frame',), ('link_text', 'identity')], ('click',))
|
||||||
|
|
||||||
# StaleElementReferenceException
|
select(driver, [('id', 'document'), ('frame',), ('id', 'create_id')], ('click',))
|
||||||
while True:
|
id0 = select(driver, [('id', 'document'), ('frame',), ('tag', 'li')]).text.split(' ')[-1]
|
||||||
try:
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'content')))
|
|
||||||
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'create_id'))).click()
|
|
||||||
driver.switch_to.alert.accept()
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# StaleElementReferenceException
|
select(driver, [('id', 'document'), ('frame',), ('xpath', '//li/button[text()="Export Identity"]')], ('click',))
|
||||||
while True:
|
select(driver, [('xpath', '//button[text()="✅ Allow"]')], ('click',))
|
||||||
try:
|
words = select(driver, [('id', 'document'), ('frame',), ('xpath', '//li//textarea')]).get_attribute('value')
|
||||||
id0 = wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'li'))).text.split(' ')[-1]
|
select(driver, [('id', 'document'), ('frame',), ('xpath', '//li/button[text()="Delete Identity"]')], ('click',))
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//li/button[text()="Export Identity"]'))).click()
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//button[text()="✅ Allow"]'))).click()
|
|
||||||
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
|
||||||
words = wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//li//textarea'))).get_attribute('value')
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//li/button[text()="Delete Identity"]'))).click()
|
|
||||||
driver.switch_to.alert.send_keys('DELETE')
|
driver.switch_to.alert.send_keys('DELETE')
|
||||||
driver.switch_to.alert.accept()
|
driver.switch_to.alert.accept()
|
||||||
driver.switch_to.default_content()
|
select(driver, [('xpath', '//button[text()="✅ Allow"]')], ('click',))
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//button[text()="✅ Allow"]'))).click()
|
driver.switch_to.alert.accept()
|
||||||
|
words = select(driver, [('id', 'document'), ('frame',), ('xpath', '//textarea')], ('send_keys', words))
|
||||||
|
select(driver, [('id', 'document'), ('frame',), ('xpath', '//button[text()="Import Identity"]')], ('click',))
|
||||||
|
select(driver, [('xpath', '//button[text()="✅ Allow"]')], ('click',))
|
||||||
driver.switch_to.alert.accept()
|
driver.switch_to.alert.accept()
|
||||||
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
||||||
words = wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//textarea'))).send_keys(words)
|
id1 = select(driver, [('id', 'document'), ('frame',), ('tag', 'li')]).text.split(' ')[-1]
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//button[text()="Import Identity"]'))).click()
|
assert id0 == id1
|
||||||
driver.switch_to.default_content()
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.XPATH, '//button[text()="✅ Allow"]'))).click()
|
|
||||||
driver.switch_to.alert.accept()
|
|
||||||
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
|
||||||
id1 = wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'li'))).text.split(' ')[-1]
|
|
||||||
|
|
||||||
driver.get('http://localhost:8888')
|
driver.get('http://localhost:8888')
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
select(driver, [('id', 'document'), ('frame',), ('link_text', 'ssb')], ('click',))
|
||||||
driver.switch_to.frame(driver.find_element(By.ID, 'document'))
|
select(driver, [('id', 'document'), ('frame',), ('tag', 'tf-app'), ('shadow_root',), ('id', 'tf-tab-news'), ('shadow_root',), ('id', 'tf-compose'), ('shadow_root',), ('id', 'edit')], ('send_keys', 'Hello, world!'))
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'ssb'))).click()
|
select(driver, [('id', 'document'), ('frame',), ('tag', 'tf-app'), ('shadow_root',), ('id', 'tf-tab-news'), ('shadow_root',), ('id', 'tf-compose'), ('shadow_root',), ('id', 'submit')], ('click',))
|
||||||
driver.switch_to.default_content()
|
select(driver, [('xpath', '//button[text()="✅ Allow"]')], ('click',))
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'content')))
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'identity')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'logout')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'login_label')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
|
|
||||||
# StaleElementReferenceException
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'identity')], ('click',))
|
||||||
while True:
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'logout')], ('click',))
|
||||||
try:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'guest_label')], ('click',))
|
||||||
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'guestButton')], ('click',))
|
||||||
break
|
select(driver, [('id', 'document'), ('frame',), ('tag', 'tf-app'), ('shadow_root',)])
|
||||||
except:
|
|
||||||
pass
|
|
||||||
# NoSuchShadowRootException
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
tf_app = wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# WebDriverException (shadow root is detached)
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'logout')], ('click',))
|
||||||
while True:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'login_label')], ('click',))
|
||||||
try:
|
|
||||||
tf_tab_news = wait.until(exists_in_shadow_root(tf_app, 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()
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
driver.switch_to.default_content()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
driver.find_element(By.ID, 'allow').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'wrong_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'error')])
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'wrong_user'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'error')])
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'content')))
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'register_label')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'wrong_test_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'confirm')], ('send_keys', 'wrong_test_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'error')])
|
||||||
|
|
||||||
while True:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'register_label')], ('click',))
|
||||||
try:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
break
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'confirm')], ('send_keys', 'test_password'))
|
||||||
except:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
pass
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'error')])
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'guest_label').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'guestButton').click()
|
|
||||||
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'content')))
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'register_label')], ('click',))
|
||||||
driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))))
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', '😁'))
|
||||||
# NoSuchShadowRootException
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
while True:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'confirm')], ('send_keys', 'test_password'))
|
||||||
try:
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
tf_app = wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'error')])
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
driver.switch_to.default_content()
|
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'change_label')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'new_password')], ('send_keys', 'new_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'confirm')], ('send_keys', 'new_password'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
|
select(driver, [('id', 'document'), ('frame',)])
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'identity')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('wrong_password')
|
select(driver, [('tag', 'tf-navigation'), ('shadow_root',), ('id', 'logout')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'login_label')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'error')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'test_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('wrong_user')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'error')])
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'login_label')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'error')
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'name')], ('send_keys', 'testuser'))
|
||||||
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'password')], ('send_keys', 'new_password'))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'register_label').click()
|
select(driver, [('tag', 'tf-auth'), ('shadow_root',), ('id', 'loginButton')], ('click',))
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
select(driver, [('id', 'document'), ('frame',)])
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('wrong_test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('wrong_test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'error')
|
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'register_label').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('1invalid')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'error')
|
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'register_label').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('😁')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'error')
|
|
||||||
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'change_label').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'new_password').send_keys('new_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('new_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click()
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'error')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click()
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('new_password')
|
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
|
||||||
wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))
|
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user