edit capabilities for sauce labs

This commit is contained in:
Churikova Tetiana 2018-04-06 14:58:07 +03:00 committed by Tetiana Churikova
parent 5d852481ee
commit 68c8e73ca5
6 changed files with 136 additions and 41 deletions

View File

@ -0,0 +1,28 @@
from pages.base_page import BasePageObject
from pages.base_element import *
from tests import test_data
import logging
class ActivityDescription(BaseText):
def __init__(self, driver, status, issue_title):
super(ActivityDescription, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'//div[@class="description"]/div[contains(.,"' + status + '")]/a[contains(.,"' + issue_title + '")]')
class ActivityPage(BasePageObject):
def __init__(self, driver):
super(ActivityPage, self).__init__(driver)
self.driver = driver
def get_activity_page(self):
self.driver.get(test_data.config['Common']['url'] + 'app#/activity')
def check_activity_is_presented(self, status, issue_title):
logging.info('Check that activity "' + status + issue_title + '" is displayed')
ActivityDescription(self.driver, status, issue_title).find_element()

View File

@ -2,7 +2,6 @@ from pages.base_page import BasePageObject
from pages.base_element import *
from tests import test_data
class BountiesHeader(BaseText):
def __init__(self, driver):
@ -36,6 +35,14 @@ class BountyFooters(BaseText):
self.locator = self.Locator.css_selector('.open-bounty-item-content .footer-row')
class BountyClaimsAmount(BaseText):
def __init__(self, driver, issue_title, claims_text):
super(BaseText, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'//div[@class="header"]/a[contains(.,"' + issue_title +'")]/../../div[@class="footer-row"]/span[contains(.,"' + claims_text + '")]')
class BountiesPage(BasePageObject):
def __init__(self, driver):
super(BountiesPage, self).__init__(driver)
@ -51,3 +58,7 @@ class BountiesPage(BasePageObject):
def get_bounties_page(self):
self.driver.get(test_data.config['Common']['url'] + 'app')
def check_bounty_claims_amount(self, issue_title, claims_text):
logging.info('Check that bounty "' + issue_title + '" has "' + claims_text + '"')
BountyClaimsAmount(self.driver, issue_title, claims_text).find_element()

View File

@ -1,11 +1,8 @@
import time, pytest
import time, pytest, git, os, shutil, logging
from pages.base_element import *
from pages.base_page import BasePageObject
from tests import test_data
from git import Repo
import os
import shutil
import logging
class EmailEditbox(BaseEditBox):
@ -151,24 +148,41 @@ class ConfirmDeleteButton(BaseButton):
super(ConfirmDeleteButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//button[text()[contains(.,'I understand the consequences, delete')]]")
class CompareAndPullRequest(BaseButton):
def __init__(self, driver):
super(CompareAndPullRequest, self).__init__(driver)
self.locator = self.Locator.css_selector(".RecentBranches a")
class PrTitleEditBox(BaseEditBox):
def __init__(self, driver):
super(PrTitleEditBox, self).__init__(driver)
self.locator = self.Locator.id("pull_request_body")
class SubmitNewPrButton(BaseButton):
def __init__(self, driver):
super(SubmitNewPrButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//button[contains(text(), "
"'Create pull request')]")
class GithubPage(BasePageObject):
def __init__(self, driver):
super(GithubPage, self).__init__(driver)
self.driver = driver
# sign in and installation related
self.email_input = EmailEditbox(self.driver)
self.password_input = PasswordEditbox(self.driver)
self.sign_in_button = SignInButton(self.driver)
self.authorize_sob = AuthorizeStatusOpenBounty(self.driver)
self.permission_type = PermissionTypeText(self.driver)
self.install_button = InstallButton(self.driver)
self.organization_button = OrganizationButton(self.driver)
self.all_repositories_button = AllRepositoriesButton(self.driver)
self.integration_permissions_group = IntegrationPermissionsGroup(self.driver)
# issue related
self.new_issue_button = NewIssueButton(self.driver)
self.issue_title_input = IssueTitleEditBox(self.driver)
self.labels_button = LabelsButton(self.driver)
@ -177,15 +191,23 @@ class GithubPage(BasePageObject):
self.submit_new_issue_button = SubmitNewIssueButton(self.driver)
self.contract_body = ContractBody(self.driver)
self.issue_id = IssueId(self.driver)
# repo forking
self.fork_button = ForkButton(self.driver)
self.header_in_fork_popup = HeaderInForkPopup(self.driver)
self.user_account_in_fork_popup = UserAccountInForkPopup(self.driver)
self.forked_repo_text = ForkedRepoText(self.driver)
# repo deleting
self.delete_repo = DeleteRepo(self.driver)
self.repo_name_confirm_delete = RepoNameBoxInPopup(self.driver)
self.confirm_delete = ConfirmDeleteButton(self.driver)
# PR related
self.compare_and_pull_request = CompareAndPullRequest(self.driver)
self.pr_body = PrTitleEditBox(self.driver)
self.submit_new_pr_button = SubmitNewPrButton(self.driver)
def get_issues_page(self):
self.driver.get(test_data.config['ORG']['gh_repo'] + 'issues')
@ -215,7 +237,7 @@ class GithubPage(BasePageObject):
self.get_issues_page()
self.new_issue_button.click()
test_data.issue = dict()
test_data.issue['title'] = 'auto_test_bounty_%s' % self.time_now
test_data.issue['title'] = 'auto_test_bounty_%s' % test_data.date_time
self.issue_title_input.send_keys(test_data.issue['title'])
self.labels_button.click()
self.bounty_label.click()
@ -245,24 +267,44 @@ class GithubPage(BasePageObject):
pytest.fail('Contract is not deployed in %s minutes!' % str(wait/60))
#cloning via HTTPS
def clone_repo(self, initial_repo=None, username=None, repo_name=None, repo_path='git_repo'):
os.mkdir(repo_path)
os.chdir(repo_path)
test_data.local_repo_path = os.getcwd()
def clone_repo(self, initial_repo=None, username=None, repo_name=None, repo_folder='test_repo'):
os.mkdir(repo_folder)
os.chdir(repo_folder)
self.local_repo_path = os.getcwd()
fork = 'https://github.com/%s/%s.git' % (username, repo_name)
logging.info(('Cloning from %s to %s' % (fork, repo_path)))
r = Repo.clone_from(fork, repo_path)
logging.info(('Successefully cloned to: %s' % test_data.local_repo_path))
logging.info(('Cloning from %s to %s' % (fork, self.local_repo_path)))
repo = git.Repo.clone_from(fork, self.local_repo_path)
logging.info(('Successefully cloned to: %s' % self.local_repo_path))
logging.info('Set upstream to %s'% initial_repo)
upstream = r.create_remote('upstream', initial_repo)
upstream = repo.create_remote('upstream', initial_repo)
upstream.fetch()
assert upstream.exists()
r.heads.master.checkout()
repo.heads.master.checkout()
def create_pr_git(self, branch, file_to_modify = 'test'):
repo = git.Repo(self.local_repo_path)
logging.info(repo.git.status())
logging.info(repo.git.pull('upstream', 'master'))
logging.info(repo.git.push('origin', 'master'))
logging.info(repo.git.fetch('--all'))
repo.git.checkout('-b',branch)
file = open(os.path.join(self.local_repo_path, file_to_modify), 'w')
file.write("Autotest change: %s \r \n" % test_data.date_time)
logging.info(repo.git.add('test'))
logging.info(repo.git.commit(m='Aut %s' % test_data.date_time))
repo.git.push('origin', branch)
def open_pr_github(self, keyword_comment):
self.get_url(test_data.config['DEV']['gh_forked_repo'])
self.compare_and_pull_request.click()
self.pr_body.send_keys(keyword_comment + ' #%s' % test_data.issue['id'])
self.submit_new_pr_button.click()
def clean_repo_local_folder(self):
logging.info('Removing %s' % test_data.local_repo_path)
if test_data.local_repo_path:
shutil.rmtree(test_data.local_repo_path)
logging.info('Removing %s' % self.local_repo_path)
if self.local_repo_path:
shutil.rmtree(self.local_repo_path)
def delete_fork(self):
self.get_url(test_data.config['DEV']['gh_forked_repo'] + 'settings')
@ -271,6 +313,3 @@ class GithubPage(BasePageObject):
self.confirm_delete.click()

View File

@ -1,20 +1,24 @@
import configparser
import os
import configparser, time, datetime, os
class TestData(object):
def __init__(self):
self.test_name = None
self.config = configparser.ConfigParser()
# define here path to your config.ini file
# example - config_example.ini
# put config.ini to /test/end-to-end/tests folder (same directory where config_example.ini is placed
self.tests_path = os.path.abspath(os.path.dirname(__file__))
self.config.read(os.path.join(self.tests_path, 'config.ini'))
self.config.read(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'config.ini'))
#create unique identificator for PRs, issues ect
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
self.date_time = st
# self.issue['title'] is set in GithubPage::create_new_bounty
# self.issue['id'] is set in GithubPage::create_new_bounty
# self.local_repo_path is set in GithubPage::clone_repo

View File

@ -1,4 +1,4 @@
import pytest, sys
import pytest, sys, os
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from tests.postconditions import remove_application, remove_installation
@ -52,8 +52,7 @@ class BaseTestCase:
# Org Chrome options
#
cls.capabilities_org = webdriver.ChromeOptions()
# doesn't work on sauce env
# cls.capabilities_org.add_extension(path.abspath(test_data.config['Paths']['tests_absolute'] + 'resources/metamask3_12_0.crx'))
cls.capabilities_org.add_extension(os.path.join(test_data.tests_path, os.pardir, 'resources', 'metamask3_12_0.crx'))
#
# SauceLab capabilities
@ -117,8 +116,7 @@ class BaseTestCase:
# Cloning repo to local git as Developer and set upstream to Organization (via HTTPS)
cls.github_dev.clone_repo(test_data.config['ORG']['gh_repo'],
test_data.config['DEV']['gh_username'],
test_data.config['ORG']['gh_repo_name'],
'git_repo')
test_data.config['ORG']['gh_repo_name'])
cls.verify_no_errors(cls)

View File

@ -1,8 +1,9 @@
import pytest
from os import environ
from pages.openbounty.landing import LandingPage
# from os import environ
# from pages.openbounty.landing import LandingPage
from pages.openbounty.bounties import BountiesPage
from pages.thirdparty.github import GithubPage
from pages.openbounty.activity import ActivityPage
# from pages.thirdparty.github import GithubPage
from tests.basetestcase import BaseTestCase
from tests import test_data
@ -17,11 +18,25 @@ class TestLogin(BaseTestCase):
self.github_org.get_deployed_contract()
# Navigate and check top bounty in "Open bounties"
bounties_page = BountiesPage(self.driver_org)
bounties_page = BountiesPage(self.driver_dev)
bounties_page.get_bounties_page()
titles = bounties_page.bounty_titles.find_elements()
assert titles[0].text == test_data.issue['title']
def test_new_claim(self):
self.github_dev.create_pr_git('test_branch_%s' % self.github_dev.time_now)
self.github_dev.open_pr_github('Fixes')
# check new claim in "Open bounties"
bounties_page = BountiesPage(self.driver_dev)
bounties_page.get_bounties_page()
bounties_page.check_bounty_claims_amount(test_data.issue['title'], '1 open claim')
# check new claim in "Activity"
activity_page = ActivityPage(self.driver_dev)
activity_page.get_activity_page()
activity_page.check_activity_is_presented('Submitted a claim for ', test_data.issue['title'])