-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from lambotik/master
Added: AQA folder
- Loading branch information
Showing
19 changed files
with
1,765 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
English-exercises-AQA/.github/workflows/EnglishActions.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: UI Tests | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
ui-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Chrome | ||
run: sudo apt-get install google-chrome-stable | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Run tests | ||
run: | | ||
pytest -s -vv --alluredir=allure-results | ||
- name: Add allure information | ||
working-directory: allure-results | ||
if: always() | ||
run: | | ||
echo GIT_BRANCH=${{ github.head_ref || github.ref_name }} >> environment.properties | ||
echo GIT_COMMIT_ID=${{ github.sha }} >> environment.properties | ||
echo GIT_COMMIT_MESSAGE=$(git show -s --format=%s HEAD) >> environment.properties | ||
echo GIT_COMMIT_AUTHOR_NAME=$(git show -s --format='%ae' HEAD) >> environment.properties | ||
echo GIT_COMMIT_TIME=$(git show -s --format=%ci HEAD) >> environment.properties | ||
echo CHROME_VERSION=$(google-chrome --product-version) >> environment.properties | ||
- name: Checkout (copy) gh-pages repository to GitHub runner | ||
uses: actions/checkout@v2 | ||
if: always() | ||
with: | ||
ref: gh-pages | ||
path: ./.github/gh-pages | ||
|
||
|
||
|
||
|
||
|
||
- name: Copy history from gh-pages to allure-results | ||
if: always() | ||
run: | | ||
sudo mkdir -p allure-results/history | ||
sudo cp -R ./.github/gh-pages/history/* allure-results/history/ | ||
- name: Generate Allure report | ||
if: always() | ||
run: | | ||
sudo docker-compose run regression /bin/sh -c "allure generate allure-results --clean -o allure-report" | ||
- name: Update Allure history | ||
if: always() | ||
run: | | ||
sudo cp -R allure-report/history/* ./.github/gh-pages/history/ | ||
- name: Deploy to GitHub Pages | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
if: always() | ||
with: | ||
token: ${{ secrets.CI_TOKEN }} | ||
branch: gh-pages | ||
folder: allure-report | ||
#clean: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pytest_cache | ||
.idea | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM python:3.12.0a4-alpine3.17 | ||
# update apk repo | ||
RUN echo "https://dl-4.alpinelinux.org/alpine/v3.10/main" >> /etc/apk/repositories && \ | ||
echo "https://dl-4.alpinelinux.org/alpine/v3.10/community" >> /etc/apk/repositories | ||
|
||
# install chromedriver | ||
RUN apk update | ||
RUN apk add --no-cache chromium chromium-chromedriver tzdata | ||
|
||
# Get all the prereqs | ||
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub | ||
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk | ||
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-bin-2.30-r0.apk | ||
|
||
RUN apk update && \ | ||
apk add openjdk11-jre curl tar && \ | ||
curl -o allure-2.13.8.tgz -Ls https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.13.8/allure-commandline-2.13.8.tgz && \ | ||
tar -zxvf allure-2.13.8.tgz -C /opt/ && \ | ||
ln -s /opt/allure-2.13.8/bin/allure /usr/bin/allure && \ | ||
rm allure-2.13.8.tgz | ||
|
||
WORKDIR /usr/workspace | ||
|
||
# Copy the dependencies file to the working directory | ||
COPY ./requirements.txt /usr/workspace | ||
|
||
# Install Python dependencies | ||
RUN pip3 install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# English-exercises-AQA | ||
Tests for [English-exercises](https://github.com/Areso/English-exercises) | ||
|
||
Current allure-report here: [Allure-report](https://lambotik.github.io/English-exercises-AQA/#) | ||
|
||
While this for simple run, later I'll correct it. | ||
|
||
1 ```git clone https://github.com/lambotik/English-exercises-AQA.git``` | ||
|
||
2 ```cd English-exercises-AQA``` | ||
|
||
3 ```pip3 install -r requirements.txt``` | ||
|
||
4 ```pytest -s -vv --alluredir=allure-results``` | ||
|
||
5 ```allure serve allure-results``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3.7' | ||
|
||
services: | ||
regression: | ||
image: python:3.12.0a4-alpine3.17 | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
volumes: | ||
- ./:/usr/workspace | ||
command: /bin/sh -c "ls -la && pytest -sv --alluredir=allure-results" | ||
working_dir: /usr/workspace | ||
environment: | ||
- LOGIN=${LOGIN} | ||
- PASSWORD=${PASSWORD} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
|
||
class PrepositionsLocators: | ||
# Chapter 1 | ||
AMOUNT_OF_CARDS = (By.XPATH, '//span[@id="spnTotal"]') | ||
CURRENT_CARD_NUMBER = (By.XPATH, '//span[@id="spnCurPos"]') | ||
QUESTION = (By.XPATH, '//div[@id="question"]') | ||
LIST_OF_RADIO_BUTTONS = (By.XPATH, '// div[@id = "answer_radiobutton_div"] /input') | ||
RADIO_BUTTON_ON = (By.XPATH, '//input[@value="on"]') | ||
RADIO_BUTTON_AT = (By.XPATH, '//input[@value="at"]') | ||
RADIO_BUTTON_IN = (By.XPATH, '//input[@value="in"]') | ||
CORRECT_OR_WRONG = (By.XPATH, '//lbl[@id="resultLbl"] /span') | ||
CHECK_ANSWER_BUTTON = (By.XPATH, '//button[@id="checkBtn"]') | ||
SHOW_ANSWER_BUTTON = (By.XPATH, '//button[@id="showAnswerBtn"]') | ||
NEXT_CARD_BUTTON = (By.XPATH, '//button[@id="nextBtn"]') | ||
CORRECT_ANSWER_TEXT = (By.XPATH, '//lbl[@id="resultLbl"]') | ||
|
||
# Chapter 2 | ||
INPUT_PLACE = (By.XPATH, '//input[@id="answer_text_field"]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import random | ||
|
||
import allure | ||
from allure_commons.types import AttachmentType | ||
from selenium.webdriver import Keys, ActionChains | ||
from selenium.webdriver.support import expected_conditions as ec | ||
from selenium.webdriver.support.ui import WebDriverWait as Wait | ||
|
||
|
||
class BasePage: | ||
|
||
def __init__(self, driver, url): | ||
self.driver = driver | ||
self.url = url | ||
self.timeout = 5 | ||
|
||
def get_current_url(self): | ||
get_url = self.driver.current_url | ||
print('Current url: ' + get_url) | ||
|
||
def open(self): | ||
with allure.step(f'Open page: {self.url}'): | ||
self.driver.get(self.url) | ||
|
||
def element_is_presence_and_clickable(self, locator): | ||
with allure.step(f'Check element is visible and clickable: {locator}'): | ||
return (Wait(self.driver, self.timeout).until(ec.visibility_of_element_located(locator), | ||
message=f"Can't find element by locator {locator}") and | ||
self.element_is_clickable(locator)) | ||
|
||
def element_is_visible(self, locator): | ||
with allure.step(f'Check element is visible: {locator}'): | ||
self.go_to_element(self.element_is_presence(locator)) | ||
return Wait(self.driver, self.timeout).until(ec.visibility_of_element_located(locator), | ||
message=f"Can't find element by locator {locator}") | ||
|
||
def elements_are_visible(self, locator): | ||
with allure.step(f'Check elements are visible: {locator}'): | ||
return Wait(self.driver, self.timeout).until(ec.visibility_of_all_elements_located(locator), | ||
message=f"Can't find elements by locator {locator}") | ||
|
||
def element_is_presence(self, locator): | ||
with allure.step(f'Check element is presence: {locator}'): | ||
return Wait(self.driver, self.timeout).until(ec.presence_of_element_located(locator), | ||
message=f"Can't find element by locator {locator}") | ||
|
||
def elements_are_presence(self, locator): | ||
with allure.step(f'Check elements are presence: {locator}'): | ||
return Wait(self.driver, self.timeout).until(ec.presence_of_all_elements_located(locator), | ||
message=f"Can't find elements by locator {locator}") | ||
|
||
def elements_is_not_visible(self, locator): | ||
with allure.step(f'Check elements is not visible: {locator}'): | ||
return Wait(self.driver, self.timeout).until(ec.invisibility_of_element(locator), | ||
message=f"Can't find element by locator {locator}") | ||
|
||
@allure.step('Check element is clickable') | ||
def element_is_clickable(self, locator): | ||
with allure.step(f'Check elements are clickable: {locator}'): | ||
return Wait(self.driver, self.timeout).until(ec.element_to_be_clickable(locator), | ||
message=f"Can't find element by locator {locator}") | ||
|
||
def go_to_element(self, element): | ||
with allure.step(f'Go to element: {element}'): | ||
return self.driver.execute_script("arguments[0].scrollIntoView({ block: 'center'});", element) | ||
|
||
def scroll_to_visible_element(self, locator): | ||
with allure.step(f'Scroll to element: {locator}'): | ||
self.go_to_element(self.element_is_presence(locator)) | ||
return Wait(self.driver, self.timeout).until(ec.element_to_be_clickable(locator), | ||
message=f"Can't find element by locator {locator}") | ||
|
||
@allure.step('Click enter to element') | ||
def click_enter_to_element(self, locator): | ||
allure.step(f'Click enter to {locator}') | ||
Wait(self.driver, self.timeout).until(ec.element_to_be_clickable(locator(Keys.RETURN))) | ||
|
||
@allure.step('Remove footer') | ||
def remove_footer(self): | ||
self.driver.execute_script("document.getElementsByTagName('footer')[0].remove();") | ||
print('\nRemove Footer') | ||
|
||
@allure.step('check_selected_radio_button') | ||
def check_selected_radio_button(self, index): | ||
result = self.driver.execute_script(f'return(document.getElementsByName("possibleAnswers")[{index}].checked)') | ||
with allure.step(f'Check value of selected button: {result}'): | ||
return result | ||
|
||
@allure.step('check_selected_radio_button') | ||
def get_entered_value(self): | ||
"""This method returned entered value from input place""" | ||
result = self.driver.execute_script(f'return(document.querySelector("#answer_text_field").value)') | ||
with allure.step(f'Check value of selected button: {result}'): | ||
return result | ||
|
||
""""Данный метод убирает рекламный банер""" | ||
|
||
@allure.step('Remove fixedban') | ||
def remove_fixedban(self): | ||
self.driver.execute_script("document.getElementById('fixedban').style.display = 'none'") | ||
print('Remove Fixedban') | ||
|
||
@allure.step('Action double click') | ||
def action_double_click(self, element): | ||
with allure.step(f'Double click {element}'): | ||
action = ActionChains(self.driver) | ||
action.double_click(element).perform() | ||
|
||
@allure.step('Action right click') | ||
def action_right_click(self, element): | ||
with allure.step(f'Right click {element}'): | ||
action = ActionChains(self.driver) | ||
action.context_click(element).perform() | ||
|
||
@allure.step('Action one click') | ||
def action_one_click(self, element): | ||
action = ActionChains(self.driver) | ||
action.click(element).perform() | ||
|
||
@allure.step('Go to a new tab') | ||
def go_to_a_new_tab(self): | ||
self.driver.switch_to.window(self.driver.window_handles[1]) | ||
|
||
@allure.step('Go to alert') | ||
def go_to_alert(self): | ||
return self.driver.switch_to.alert | ||
|
||
@allure.step('Go to frame') | ||
def go_to_frame(self, element): | ||
self.driver.switch_to.frame(element) | ||
|
||
@allure.step('Switch to default content') | ||
def switch_to_default_content(self): | ||
self.driver.switch_to.default_content() | ||
|
||
@allure.step('Random choice from elements list') | ||
def random_choice_from_elements_list(self, elements_list_locator): | ||
empty_list = [] | ||
full_list = self.elements_are_presence(elements_list_locator) | ||
for t in full_list: | ||
empty_list.append(t.text) | ||
return random.choice(full_list) | ||
|
||
@allure.step('Action drag and drop offset') | ||
def action_drag_and_drop_offset(self, element, x_coord, y_coord): | ||
action = ActionChains(self.driver) | ||
action.drag_and_drop_by_offset(element, x_coord, y_coord) | ||
action.perform() | ||
|
||
@allure.step('Action move to element') | ||
def action_move_to_element(self, element): | ||
with allure.step(f'Move to {element}'): | ||
action = ActionChains(self.driver) | ||
action.move_to_element(element) | ||
action.perform() | ||
|
||
@allure.step('Action drag and drop element') | ||
def action_drag_and_drop_element(self, what, where): | ||
action = ActionChains(self.driver) | ||
action.drag_and_drop(what, where) | ||
action.perform() | ||
|
||
@allure.step('Attach screenshot') | ||
def attach_screenshot(self, element): | ||
"""Create screenshot of current window and attach it in allure report | ||
Args: | ||
- file_name: str like 'Linkedin_button_not_found' | ||
""" | ||
element_name = ''.join(element) | ||
allure.attach(self.driver.get_screenshot_as_png(), name=element_name, attachment_type=AttachmentType.PNG) |
Oops, something went wrong.