Lanhui-Selenium #19
|
@ -0,0 +1,13 @@
|
|||
import pytest
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
@pytest.fixture
|
||||
def URL():
|
||||
return 'http://127.0.0.1:5000' # URL of the program
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def driver():
|
||||
my_driver = webdriver.Edge() # uncomment this line if you wish to run the test on your laptop
|
||||
return my_driver
|
|
@ -6,19 +6,18 @@ from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|||
|
||||
import random, time
|
||||
import string
|
||||
import pytest
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
|
||||
def has_punctuation(s):
|
||||
return [c for c in s if c in string.punctuation] != []
|
||||
|
||||
def test_add_word():
|
||||
|
||||
@pytest.mark.usefixtures
|
||||
def test_add_word(URL, driver):
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
assert 'English Pal -' in driver.page_source
|
||||
|
||||
# login
|
||||
|
|
|
@ -3,22 +3,21 @@
|
|||
# docker run -d -p 4444:4444 selenium/standalone-chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
import pytest
|
||||
import random, time
|
||||
import string
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
|
||||
|
||||
def has_punctuation(s):
|
||||
return [c for c in s if c in string.punctuation] != []
|
||||
|
||||
def test_add_word_and_essay_does_not_change():
|
||||
|
||||
@pytest.mark.usefixtures
|
||||
def test_add_word_and_essay_does_not_change(URL, driver):
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
assert 'English Pal -' in driver.page_source
|
||||
|
||||
# login
|
||||
|
|
|
@ -3,25 +3,22 @@
|
|||
# docker run -d -p 4444:4444 selenium/standalone-chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
import pytest
|
||||
import random, time
|
||||
import string
|
||||
|
||||
# 调用本地chromedriver
|
||||
# driver = webdriver.Chrome(executable_path="D:\ChromeDriver\chromedriver.exe")
|
||||
# driver.get("http://127.0.0.1:5000/")
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
# driver.maximize_window()
|
||||
# HOME_PAGE = "http://127.0.0.1:5000/"
|
||||
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures
|
||||
def test_delete_word():
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
assert 'English Pal -' in driver.page_source
|
||||
# login
|
||||
elem = driver.find_element_by_link_text('登录')
|
||||
|
@ -58,4 +55,3 @@ def test_delete_word():
|
|||
finally:
|
||||
driver.quit()
|
||||
|
||||
# test_delete_word()
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
# docker run -d -p 4444:4444 selenium/standalone-chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
import pytest
|
||||
import random, string
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
|
||||
|
||||
|
||||
def test_login():
|
||||
@pytest.mark.usefixtures
|
||||
def test_login(URL, driver):
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
driver.save_screenshot('./app/test/test_login_pic0.png')
|
||||
|
||||
assert 'English Pal -' in driver.page_source
|
||||
|
@ -41,7 +39,7 @@ def test_login():
|
|||
assert uname in driver.page_source
|
||||
|
||||
# logout
|
||||
driver.get(HOME_PAGE + 'logout')
|
||||
driver.get(URL + 'logout')
|
||||
driver.save_screenshot('./app/test/test_login_pic3.png')
|
||||
|
||||
# login
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
# docker run -d -p 4444:4444 selenium/standalone-chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
import pytest
|
||||
import random, string
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
|
||||
@pytest.mark.usefixtures
|
||||
def test_login_security_fix():
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
|
||||
elem = driver.find_element_by_link_text('登录')
|
||||
elem.click()
|
||||
|
|
|
@ -3,19 +3,16 @@
|
|||
# docker run -d -p 4444:4444 selenium/standalone-chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
import pytest
|
||||
import random, string, time
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
|
||||
|
||||
|
||||
def test_next():
|
||||
@pytest.mark.usefixtures
|
||||
def test_next(URL, driver):
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
assert 'English Pal -' in driver.page_source
|
||||
|
||||
# login
|
||||
|
|
|
@ -6,15 +6,10 @@ Click the Familiar or Unfamiliar button (current word frequency is 1), and the p
|
|||
from random import randint
|
||||
|
||||
from selenium import webdriver
|
||||
import pytest
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
|
||||
|
||||
def click_by_random(text):
|
||||
elements = driver.find_elements_by_link_text(text) # 点击单词表中的第一个单词的熟悉按钮
|
||||
elements[randint(0, len(elements) - 1)].click()
|
||||
|
@ -33,10 +28,10 @@ def get_scrollTop():
|
|||
roll_height = driver.execute_script(js)
|
||||
return roll_height
|
||||
|
||||
|
||||
def test_page_position():
|
||||
@pytest.mark.usefixtures
|
||||
def test_page_position(URL, driver):
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
# login
|
||||
driver.find_element_by_link_text('登录').click()
|
||||
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
# docker run -d -p 4444:4444 selenium/standalone-chrome
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
|
||||
import pytest
|
||||
import random, string
|
||||
|
||||
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
driver.implicitly_wait(10)
|
||||
|
||||
HOME_PAGE = 'http://121.4.94.30:91/'
|
||||
#driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.FIREFOX)
|
||||
#driver.implicitly_wait(10)
|
||||
|
||||
|
||||
|
||||
def test_signup():
|
||||
|
||||
@pytest.mark.usefixtures
|
||||
def test_signup(URL, driver):
|
||||
try:
|
||||
driver.get(HOME_PAGE)
|
||||
driver.get(URL)
|
||||
driver.save_screenshot('test_signup_pic0.png')
|
||||
|
||||
assert 'English Pal -' in driver.page_source
|
||||
|
|
Loading…
Reference in New Issue