def test_WrongMail(self):
     newpath = TestSettings.CreatePath() + "WrongMail"
     if not os.path.exists(newpath):
         os.makedirs(newpath)
     self.driver.get("https://www.epicgames.com/")  # переход на сайт
     self.driver.get_screenshot_as_file(
         TestSettings.TakeScreenshot(newpath))
     button = Helpers(self.driver)
     button.find_element_by_xpath("//div[@id='user']")
     # self.driver.find_element_by_xpath("//div[@id='user']").click()
     self.driver.find_element_by_xpath(
         "//a[@id='switchPageAction']").click()
     self.driver.find_element_by_xpath("//input[@id='name']").send_keys(
         "Тест")
     self.driver.find_element_by_xpath("//input[@id='lastName']").send_keys(
         "Тестовый")
     self.driver.find_element_by_xpath(
         "//input[@id='displayName']").send_keys("Selenium_test")
     self.driver.find_element_by_xpath("//input[@id='email']").send_keys(
         "test mail")
     self.driver.find_element_by_xpath("//input[@id='password']").send_keys(
         "testPassword1")
     self.driver.find_element_by_xpath(
         "//div[@class='checkContainer termsAgree filled']").click()
     self.driver.find_element_by_xpath(
         "//div[@class='btnContainer filled']").click()
     assert "Введите действующий адрес электронной почты." in self.driver.page_source
     self.driver.get_screenshot_as_file(
         TestSettings.TakeScreenshot(newpath))
示例#2
0
    def jinja_environment(self):
        jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(
            os.path.join(os.path.dirname(__file__), '../templates')))
        jinja_environment.globals['session'] = self.session

        # def get_user_profile_main_image(link):
        #     return 'saim its working'

        jinja_environment.globals['get_user_profile_main_image'] = Helpers(
        ).get_user_profile_main_image
        jinja_environment.globals['get_user_object_from_user_id'] = Helpers(
        ).get_user_object_from_user_id
        jinja_environment.globals['check_dictionary'] = Helpers(
        ).check_dictionary
        jinja_environment.globals['get_timezone'] = Helpers().get_timezone
        return jinja_environment
示例#3
0
    def AddAccount(self, AccountName, AccountType, EnableDownloadPrint):
        print("...Adding a " + AccountName + " Account...")

        chromedriver = r"F:\software\chromedriver"
        os.environ["webdriver.chrome.driver"] = chromedriver
        driver = webdriver.Chrome(chromedriver)

        h = Helpers()
        h.userLogin(driver, 'admin')
        driver.maximize_window()
        self.wait = WebDriverWait(driver, 20)

        self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addAccountBtn))).click()

        # Account Name
        self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, "input[id$='Name']"))).send_keys(AccountName)

        # EIP URL
        selectEipUrl = Select(
            self.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "select[id$='EipUrl']"))))
        selectEipUrl.select_by_visible_text("Custom URL")

        # Account Type
        selectAccountType = Select(
            self.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "select[id$='AccountType']"))))
        if AccountType == "Ent":
            selectAccountType.select_by_visible_text("Enterprise Edition")
        elif AccountType == "Pro":
            selectAccountType.select_by_visible_text("Pro Edition")
        elif AccountType == "Std":
            selectAccountType.select_by_visible_text("Standard Edition")

        # Custom EIP URL
        self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR,
                 "input[id$='CustomUrl']"))).send_keys(V.CustomEipUrl)

        # Enable Download to Print
        if EnableDownloadPrint:
            self.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR,
                     "input[id$='DownloadToPrintEnabled']"))).click()

        time.sleep(1)
        self.wait.until(EC.presence_of_element_located(
            (By.XPATH, V.saveBtn))).click()
        print("...Successful!!\n")
示例#4
0
 def __init__(self, PageHeap=False):
     print('[+] ' + datetime.now().strftime("%Y:%m:%d::%H:%M:%S") +
           ' Using Win32Com for fuzzing')
     self.ph = PageHeap
     self.help = Helpers()
     self.iePiD_p = None
     self.iePid_c = None
     self.StartUpPage = 'file://' + os.getcwd().replace(
         '\\', '/') + '\\Start.html'.replace('\\', '/')
示例#5
0
    def test_AddLoginForm(self):
        print('TC - Add Login Form...')
        self.wait = WebDriverWait(self.driver, 20)
        h = Helpers()
        h.userLogin(self.driver, 'user')
        time.sleep(1)

        self.driver.get(V.loginFormUrl)
        self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, V.addLoginFormBtn))).click()

        self.wait.until(EC.presence_of_element_located((By.XPATH, V.uploadLoginForm))).click()
        time.sleep(1)
        pyautogui.typewrite(r"F:\Login Forms\LOGIN PAGES TEMPLATES\new-login.pdf")
        time.sleep(1)
        pyautogui.keyDown('enter')
        time.sleep(1)

        self.wait.until(EC.presence_of_element_located((By.XPATH, V.saveBtn))).click()
示例#6
0
 def __init__(self):
     self.helpers = Helpers()
示例#7
0
class Automations:

    chromedriver = r"F:\software\chromedriver"
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver = webdriver.Chrome(chromedriver)

    h = Helpers()
    h.userLogin(driver, 'admin')
    driver.maximize_window()
    wait = WebDriverWait(driver, 20)

    def __init__(self):
        pass

    # Add an account
    def AddAccount(self, AccountName, AccountType, EnableDownloadPrint):
        print("...Adding a " + AccountName + " Account...")

        chromedriver = r"F:\software\chromedriver"
        os.environ["webdriver.chrome.driver"] = chromedriver
        driver = webdriver.Chrome(chromedriver)

        h = Helpers()
        h.userLogin(driver, 'admin')
        driver.maximize_window()
        self.wait = WebDriverWait(driver, 20)

        self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addAccountBtn))).click()

        # Account Name
        self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, "input[id$='Name']"))).send_keys(AccountName)

        # EIP URL
        selectEipUrl = Select(
            self.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "select[id$='EipUrl']"))))
        selectEipUrl.select_by_visible_text("Custom URL")

        # Account Type
        selectAccountType = Select(
            self.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "select[id$='AccountType']"))))
        if AccountType == "Ent":
            selectAccountType.select_by_visible_text("Enterprise Edition")
        elif AccountType == "Pro":
            selectAccountType.select_by_visible_text("Pro Edition")
        elif AccountType == "Std":
            selectAccountType.select_by_visible_text("Standard Edition")

        # Custom EIP URL
        self.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR,
                 "input[id$='CustomUrl']"))).send_keys(V.CustomEipUrl)

        # Enable Download to Print
        if EnableDownloadPrint:
            self.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR,
                     "input[id$='DownloadToPrintEnabled']"))).click()

        time.sleep(1)
        self.wait.until(EC.presence_of_element_located(
            (By.XPATH, V.saveBtn))).click()
        print("...Successful!!\n")

    # ADD WATERMARKS
    def addWatermarks(self, wmType, name, wmText, placement):

        Automations.driver.get(V.watermarkUrl)

        # 'ADD WATERMARK' button
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addWmBtn))).click()

        if wmType == 'to':
            select = Select(
                Automations.wait.until(
                    EC.presence_of_element_located(
                        (By.CSS_SELECTOR, "select[id$='SetContentAt']"))))
            select.select_by_value("DocumentProcessingTime")

            # define watermark name
            wmNameElem = Automations.wait.until(
                EC.presence_of_all_elements_located(
                    (By.CSS_SELECTOR, V.watermarkName)))
            wmNameElem[0].send_keys(name)

            # define watermark text
            wmTextElem = Automations.wait.until(
                EC.presence_of_element_located(
                    (By.XPATH, "//input[@placeholder='e.g. CONFIDENTIAL']")))
            wmTextElem.send_keys(wmText)

            # define placement
            if placement == 'up':
                upPosition = Automations.wait.until(
                    EC.presence_of_element_located(
                        (By.CSS_SELECTOR, "[data-id='up']")))
                upPosition.click()
            elif placement == 'down':
                downPosition = Automations.wait.until(
                    EC.presence_of_element_located(
                        (By.CSS_SELECTOR, "[data-id='down']")))
                downPosition.click()

            # Save and Exit
            time.sleep(2)
            saveBtn = Automations.wait.until(
                EC.presence_of_element_located((By.XPATH, V.saveBtn)))
            saveBtn.click()

        elif wmType == 'us':
            # define watermark name
            wmNameElem = Automations.wait.until(
                EC.presence_of_all_elements_located(
                    (By.CSS_SELECTOR, V.watermarkName)))
            wmNameElem[0].send_keys(name)

            # define watermark text
            wmTextElem = Automations.wait.until(
                EC.presence_of_element_located((By.XPATH, V.watermarkText)))
            wmTextElem.send_keys(wmText)

            # Save and Exit
            time.sleep(2)
            saveBtn = Automations.wait.until(
                EC.presence_of_element_located((By.XPATH, V.saveBtn)))
            saveBtn.click()

    def addPolicy(self, policyName, expiryDate, expiryAfterUnlock,
                  offlineAccess, OpenLimit, totalLimit, pdfLimit, browserLimit,
                  webPrint, downloadPrint, accountLimit, ipLimit):

        Automations.driver.get(V.drmPolicyUrl)

        # 'ADD DRM POLICY' button
        RunAutomation.wait.until(
            EC.presence_of_element_located((By.XPATH, V.addDRMBtn))).click()

        policyNameElem = Automations.wait.until(
            EC.presence_of_element_located((By.XPATH, V.policyNameField)))
        policyNameElem.send_keys(policyName)

        time.sleep(1)

        ################### EXPIRATION CONTROL ###################

        # Expiry Date
        if expiryDate == 'Never':
            ExpiryDateElem = Automations.wait.until(
                EC.presence_of_all_elements_located(
                    (By.XPATH, "//*[contains(@name, 'ExpiryF')]")))
            ExpiryDateElem[1].click()
        elif expiryDate != 'Not Set':
            ExpiryDateElem = Automations.wait.until(
                EC.presence_of_all_elements_located(
                    (By.CLASS_NAME, 'date-picker-group')))
            ActionChains(Automations.driver).move_to_element(
                ExpiryDateElem[0]).click().send_keys(expiryDate).perform()

        # Expiry After First Unlock
        ExpiryUnlockElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'RelativeExpiryInDaysF')]")))
        if expiryAfterUnlock == 'Never':
            ExpiryUnlockElem[1].click()
        elif expiryAfterUnlock != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                ExpiryUnlockElem[2]).click().send_keys(
                    expiryAfterUnlock).perform()

        ################### ACCESS CONTROL ###################

        # Offline Access
        offineAccessElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'OfflineDurationinDaysF')]")))
        if offlineAccess == 'Never':
            offineAccessElem[1].click()
        elif offlineAccess != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                offineAccessElem[2]).click().send_keys(
                    offlineAccess).perform()

        # Content Open Limit
        openLimitElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'OpenLimitF')]")))
        if offlineAccess == 'Never':
            openLimitElem[1].click()
        elif offlineAccess != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                openLimitElem[2]).click().send_keys(OpenLimit).perform()

        ################### PDF/BROWSER CONTROL ###################

        totalLimitElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'ComputersMaxF')]")))
        if totalLimit == 'Never':
            totalLimitElem[1].click()
        elif totalLimit != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                totalLimitElem[2]).click().send_keys(totalLimit).perform()

        ################### PRINT CONTROL ###################

        # Web Browser Print Limit
        webPrintLimitElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'WebPrintLimitF')]")))
        if webPrint == 'Never':
            webPrintLimitElem[1].click()
        elif webPrint != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                webPrintLimitElem[2]).click().send_keys(webPrint).perform()

        # Download to Print Limit
        # It took me a while to figure out the following xpath expression!!
        downloadPrintLimitElem = Automations.wait.until(
            EC.presence_of_all_elements_located((
                By.XPATH,
                "//*[contains(@name, 'PrintLimitF') and not(contains(@name, 'WebPrintLimitF'))]"
            )))
        if downloadPrint == 'Never':
            downloadPrintLimitElem[1].click()
        elif downloadPrint != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                downloadPrintLimitElem[2]).click().send_keys(
                    downloadPrint).perform()

        ################### OTHER CONTROLS ###################

        # Library or Account Limit
        accountLimitElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'DocumentLimitF')]")))
        if accountLimit == 'Never':
            accountLimitElem[1].click()
        elif accountLimit != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                accountLimitElem[2]).click().send_keys(accountLimit).perform()

        # IP Address Limit
        ipLimitElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.XPATH, "//*[contains(@name, 'IpAddressesMaxF')]")))
        if ipLimit == 'Never':
            ipLimitElem[1].click()
        elif ipLimit != 'Not Set':
            ActionChains(Automations.driver).move_to_element(
                ipLimitElem[2]).click().send_keys(ipLimit).perform()

        time.sleep(2)
        Automations.wait.until(
            EC.presence_of_element_located((By.XPATH, V.saveBtn))).click()

    def addContentSettings(self, csType, name, allowPrinting, allowCP,
                           selectWatermark, disableAnnotation, casePassword):

        Automations.driver.get(V.contentSettingsUrl)

        # 'ADD SETTINGS' button
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addCSBtn))).click()

        # define name of Content Settings
        csNameElem = Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, "input[id$='Name']")))
        csNameElem.send_keys(name)

        # Allow Printing
        if allowPrinting == 'true':
            Automations.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "input[id$='AllowPrint']"))).click()

        # Allow copy and paste
        if allowCP == 'true':
            Automations.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "input[id$='AllowCopy']"))).click()

        # Select Login Form
        selectLoginForm = Select(
            Automations.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "select[id$='FormId']"))))
        # selectLoginForm.select_by_visible_text("new-login")

        # Select first watermark
        selectWatermark = Select(
            Automations.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "select[id^='MultipleSelectionForm']"))))
        selectWatermark.select_by_visible_text('Test Computer ID')

        # TODO: select more watermarks

        # go to the next Tab
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.LINK_TEXT, "Advanced Options"))).click()

        # disable annotation
        if disableAnnotation == 'true':
            Automations.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR,
                     "input[id$='DisableAnnotations']"))).click()

        # if using a non-Case Sensitive password
        if casePassword == 'false':
            Automations.wait.until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR,
                     "input[id$='CaseSensitivePassword']"))).click()

        time.sleep(2)
        saveBtn = Automations.wait.until(
            EC.presence_of_element_located((By.XPATH, V.saveBtn)))
        saveBtn.click()

    # ADD SINGLE USERS
    def addSingleUsers(self, name, password, notes, externalKey, customField):

        Automations.driver.get(V.usersUrl)
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addSingleUserBtn))).click()

        uNameElem = Automations.wait.until(
            EC.presence_of_element_located((By.CSS_SELECTOR, V.uName)))
        uNameElem.send_keys(name)

        uPasswordElem = Automations.wait.until(
            EC.presence_of_element_located((By.CSS_SELECTOR, V.uPassword)))
        uPasswordElem.send_keys(password)

        uNotesElem = Automations.wait.until(
            EC.presence_of_element_located((By.CSS_SELECTOR, V.uNotes)))
        uNotesElem.send_keys(notes)

        uKeyElem = Automations.wait.until(
            EC.presence_of_element_located((By.CSS_SELECTOR, V.uKey)))
        uKeyElem.send_keys(externalKey)

        uFieldElem = Automations.wait.until(
            EC.presence_of_element_located((By.CSS_SELECTOR, V.uField)))
        uFieldElem.send_keys(customField)

        time.sleep(2)
        Automations.wait.until(
            EC.presence_of_element_located((By.XPATH, V.saveBtn))).click()

    # ADD MULTIPLE USERS
    def addMultipleUsers(self, name0, password0, name1, password1, name2,
                         password2, name3, password3, name4, password4, name5,
                         password5):

        Automations.driver.get(V.usersUrl)
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addMultipleUserBtn))).click()

        time.sleep(1)
        # Strategy: make sure the 'ADD ANOTHER' button is functional
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addOneMoreUserBtn))).click()

        uNameElem = Automations.wait.until(
            EC.presence_of_all_elements_located((By.CSS_SELECTOR, V.uName)))
        uPasswordElem = Automations.wait.until(
            EC.presence_of_all_elements_located(
                (By.CSS_SELECTOR, V.mPassword)))

        # USER 0
        uNameElem[0].send_keys(name0)
        uPasswordElem[0].send_keys(password0)

        # USER 1
        uNameElem[1].send_keys(name1)
        uPasswordElem[1].send_keys(password1)

        # USER 2
        uNameElem[2].send_keys(name2)
        uPasswordElem[2].send_keys(password2)

        # USER 3
        uNameElem[3].send_keys(name3)
        uPasswordElem[3].send_keys(password3)

        # USER 4
        uNameElem[4].send_keys(name4)
        uPasswordElem[4].send_keys(password4)

        # USER 5
        uNameElem[5].send_keys(name5)
        uPasswordElem[5].send_keys(password5)

        time.sleep(2)
        Automations.wait.until(
            EC.presence_of_element_located((By.XPATH, V.saveBtn))).click()

    # Protect a content
    def protectContent(self, FilePath):
        Automations.driver.get(V.contentUrl)
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.CSS_SELECTOR, V.addContentBtn))).click()
        time.sleep(3)
        Automations.wait.until(
            EC.presence_of_element_located(
                (By.XPATH, V.uploadContentBtn))).click()

        time.sleep(1)
        pyautogui.typewrite(FilePath)
        time.sleep(1)
        pyautogui.keyDown('enter')
        time.sleep(2)

        Automations.wait.until(
            EC.presence_of_element_located((By.XPATH, V.saveBtn))).click()
        time.sleep(1)
示例#8
0
def Pearsonr(x, y):
    Helpers().List_Print(x, y)
    R = pearsonr(x, y)
    print("Pearson R value:", R)
    return R
示例#9
0
import numpy as np


def Pearsonr(x, y):
    Helpers().List_Print(x, y)
    R = pearsonr(x, y)
    print("Pearson R value:", R)
    return R


x = [1, 2, 3, 4, 5]
y = [12, 96, -100, -500, 111]
Feature = np.array(x)
Value = np.array(y)
Helpers().Print_Type_And_Value(Feature, Value)
Pearsonr(x, y)
Linear_Regression().Predict_With_Linear_Regression(Feature, Value, 5)

Age_Income = {
    'City': {
        'Age': 20,
        'Salary': 8000,
        'Age1': 30,
        'Salary1': 4500,
        'Age2': 40,
        'Salary2': 6500,
    },
    'Village': {
        'Age': 20,
        'Salary': 8000 * 2,