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