Beispiel #1
0
def slack_panel():
    driver.execute_script("window.open('https://jojack.slack.com/');")
    driver.switch_to_window(driver.window_handles[2])  # SHOW SLACK
    time.sleep(7)  # WAIT 7 SECONDS!

    mail = driver.find_element_by_css_selector('input[type="email"]')
    mail.send_keys(credentials.slack_mail)
    time.sleep(3)
    ps = driver.find_element_by_css_selector('input[type="password"]')
    ps.send_keys(credentials.slack_pass)

    submit_button = driver.find_element_by_xpath(
        '/html/body/div[1]/div[1]/div[2]/div/form/p[5]/button')
    submit_button.click()
    time.sleep(1)
    jump_to = driver.find_element_by_xpath(
        "/html/body/div[2]/div/div/div[3]/div/nav/div[1]/button")
    jump_to.click()
    search_for_channel = driver.find_element_by_xpath(
        "/html/body/div[6]/div/div/div/div[1]/div/div/div[1]/p")
    search_for_channel.send_keys("Cengiz")
    time.sleep(1)
    search_for_channel.send_keys(Keys.ENTER)
    time.sleep(5)

    driver.switch_to_window(driver.window_handles[0])  # SHOW THE MM PANEL
Beispiel #2
0
def test_ext_links(driver):
    test_login(driver)
    driver.get(
        "http://localhost/litecart/public_html/admin/?app=countries&doc=countries"
    )
    driver.find_element_by_xpath(".//*[@id='content']/div/a").click()
    all_ex_link = driver.find_elements_by_xpath(
        ".//*[@id='content']/form/table//a[@target='_blank']")
    print("Total ext_link: " + str(len(all_ex_link)))
    # получаем набор текущих открытых окон
    main_window = driver.current_window_handle
    print('main_window')
    print(main_window)
    old_windows = driver.window_handles
    print('old_windows')
    print(old_windows)
    # нажимаем на ссылку, которая открывает документ в новом окне
    for j in range(2):
        for i in range(len(all_ex_link)):
            print("i=" + str(i))
            with wait_for_new_window(driver, 10):
                all_ex_link[i].click()
            # получаем новый набор включающий уже новое окно
            new_windows = driver.window_handles
            print('new_windows')
            print(new_windows)
            # получаем новые окна (из одного списка вычтем другой)
            new_window = list(set(new_windows).difference(old_windows))
            print('new_window')
            print(new_window)
            # закрываем новое окно
            driver.switch_to_window(new_window[0])
            driver.close()
            driver.switch_to_window(main_window)
Beispiel #3
0
def money_matrix_panel():
    driver.get(links.money_matrix_link)
    time.sleep(10)  # WAIT 10 SECONDS!

    w_pending = driver.find_element_by_class_name(
        'transactionsWorkspacesListItemSpan')
    w_pending.click()
    time.sleep(6)  # WAIT 6 SECONDS!

    drop_down_button = driver.find_element_by_xpath(
        "//span[@class='icon icon-dropdown']")
    drop_down_button.click()
    time.sleep(1)
    reporting5_open = driver.find_element_by_xpath(
        "//li[@class='Product ProductReporting5 ng-scope ng-isolate-scope']")
    reporting5_open.click()
def cp10_cid():
    if len(filtered_cid) > 0:
        time.sleep(2)   # WAIT 2 SECONDS!
        # SHOW THE REPORTING5 PANEL
        driver.switch_to_window(driver.window_handles[1])

        userid_box = driver.find_element_by_name(
            'txtUserID')       # Reporting5
        # Reporting5
        userid_box.clear()
        userid_box.send_keys(filtered_cid[-1])

        show_report = driver.find_element_by_name(
            'btnShowReport')  # Reporting5
        show_report.click()

        time.sleep(2)
        get_data_from_r5()

    else:
        refresh_button = driver.find_element_by_xpath(
            "/html/body/div/div/div[2]/div/div/div/div/div/ui-view/div/div/div[2]/div/section/div[3]/button[1]")
        refresh_button.click()
        time.sleep(10)   # WAIT 10 SECONDS!
        get10_cid()
Beispiel #5
0
def test_menu_header(driver):
    test_login(driver)
    link_array = []
    h1_array = []
    # основное меню
    menu = driver.find_elements_by_xpath(
        "//*[@id='app-']/a/span[@class='name']")  # количество пунктов
    for i in range(len(menu)):
        # после клика загрузится новая страница и все элементы, найденные ранее, будут считаться "протухшими" (stale),
        # с ними нельзя больше ничего делать # ищем список по новому и выбираем нужный элемент по индексу
        menu_el = driver.find_elements_by_xpath(
            "//*[@id='app-']/a/span[@class='name']")
        link_name = menu_el[i].text  # имя пункта главного меню
        print(str(i) + "." + link_name)
        # переходим к пункту основного меню
        menu_el[i].click()

        # ищем пункты подменю
        driver.implicitly_wait(5)
        sub_menu = driver.find_elements_by_xpath(
            "//ul[@class='docs']//li//span")
        print("Total submenu elements:" + str(len(sub_menu)))

        if len(sub_menu) < 1:
            head_title = driver.find_element_by_xpath(
                "//td[@id='content']//h1//span").text
            print("Main Link_text  : " + link_name)
            print("Head_title : " + head_title)
            link_array.append(link_name)
            h1_array.append(head_title)
        for j in range(len(sub_menu)):
            sub_menu_el = driver.find_elements_by_xpath(
                "//ul[@class='docs']//li//span")
            sub_menu_el[j].click()
            sub_menu_el = driver.find_elements_by_xpath(
                "//ul[@class='docs']//li//span")
            sub_m_link_name = sub_menu_el[j].text  # имя пункта главного меню
            head_title2 = driver.find_element_by_xpath(
                "//td[@id='content']//h1//span").text
            print("Link_text  : " + sub_m_link_name)
            print("Head_title : " + head_title2)
            link_array.append(sub_m_link_name)
            h1_array.append(head_title2)

    print(link_array)
    print(h1_array)
    assert len(link_array) == len(h1_array)
Beispiel #6
0
def test_new_product_add(driver):
    test_login(driver)
    name_of_new_prod = get_random_name(letters, 10)

    driver.find_element_by_link_text("Catalog").click()
    driver.find_element_by_link_text("Add New Product").click()

    driver.find_element_by_css_selector("label").click()
    if not driver.find_element_by_name("status").is_selected():
        driver.find_element_by_name("status").click()

    find_and_fill_element(driver,
                          element_name='name[en]',
                          value=name_of_new_prod)
    find_and_fill_element(driver, element_name='code', value='7')
    find_and_fill_element(driver, element_name='quantity', value='11')
    # driver.find_element_by_name('new_images[]').send_keys('/home/taipan/selenium/selenium_test/img/duck_image.png')
    driver.find_element_by_name('new_images[]').send_keys(img_path)
    driver.find_element_by_name('date_valid_from').click()
    driver.find_element_by_name('date_valid_from').send_keys('2017-12-12')
    driver.find_element_by_name('date_valid_to').click()
    driver.find_element_by_name('date_valid_to').send_keys('2019-12-12')

    driver.find_element_by_link_text("Information").click()
    if not driver.find_element_by_xpath(
            "//div[@id='tab-information']//select[normalize-space(.)='-- Select -- ACME Corp.']//option[2]"
    ).is_selected():
        driver.find_element_by_xpath(
            "//div[@id='tab-information']//select[normalize-space(.)='-- Select -- ACME Corp.']//option[2]"
        ).click()

    find_and_fill_element(driver, element_name='keywords', value='my_duck')
    find_and_fill_element(driver,
                          element_name='short_description[en]',
                          value='my_duck')

    driver.find_element_by_link_text("Prices").click()
    driver.find_element_by_name("purchase_price").send_keys("22")
    if not driver.find_element_by_xpath(
            "//div[@id='tab-prices']/table[1]/tbody/tr/td/select//option[2]"
    ).is_selected():
        driver.find_element_by_xpath(
            "//div[@id='tab-prices']/table[1]/tbody/tr/td/select//option[2]"
        ).click()

    find_and_fill_element(driver, element_name='prices[USD]', value='23')

    driver.find_element_by_name("save").click()
    driver.find_element_by_id("content").click()

    # проверим что товар появился на странице просто сравнив его имя
    driver.find_element_by_link_text("Catalog").click()
    test = "//a[text()='" + str(name_of_new_prod) + "']"
    assert_element = driver.find_elements_by_xpath(test)
    print(len(assert_element))
    assert len(assert_element) == 1
def get_data_from_r5():
    counter_withdraw = 0
    for row in range(2, 53):
        number_row = driver.find_element_by_xpath(
            f"/html/body/form/div[3]/div[4]/table/tbody/tr[{row}]/td[2]")
        filtered_number_row.append(number_row.text)
        if len(filtered_number_row[-1]) != 9:
            break
    for i in range(2, row):
        trans_type = driver.find_element_by_xpath(
            f"/html/body/form/div[3]/div[4]/table/tbody/tr[{i}]/td[20]")
        filtered_trans_type.append(trans_type.text)

        debit_amount = driver.find_element_by_xpath(
            f"/html/body/form/div[3]/div[4]/table/tbody/tr[{i}]/td[13]")
        amount.append(debit_amount.text)

        last_note = driver.find_element_by_xpath(
            f"/html/body/form/div[3]/div[4]/table/tbody/tr[{i}]/td[25]")
        filtered_last_note.append(last_note.text[0:2].lower())

        if len(amount[-1]) > 7:
            amount[-1] = amount[-1].replace(',', '')
        balance = float(amount[-1])

        if filtered_trans_type[-1] == "Deposit" or filtered_trans_type[-1] == "Vendor2User":
            if filtered_trans_type[-1] == "Vendor2User" and balance == 0.00:
                continue
            break

        if filtered_last_note[-1] == "gh":
            break

        if filtered_trans_type[-1] == "Withdraw" and balance >= 5.00:
            counter_withdraw += 1
    find_deposit(filtered_trans_type, amount, balance, counter_withdraw)
def approve_withdraw():
    driver.switch_to_window(driver.window_handles[2])
    send_message = driver.find_element_by_xpath(
        "/html/body/div[2]/div/div/div[4]/div/div/footer/div/div/div[1]/div/div[1]")
    send_message.send_keys(
        filtered_time_withdraw[-1], " ", filtered_cid[-1], " - ", cek_ok)
    send_message.send_keys(Keys.ENTER)
    amount.clear()
    filtered_trans_type.clear()
    filtered_last_note.clear()
    filtered_number_row.clear()
    del filtered_cid[-1]
    del filtered_time_withdraw[-1]
    driver.switch_to_window(driver.window_handles[0])
    cp10_cid()
Beispiel #9
0
def reporting5_panel():

    if len(driver.window_handles) > 1:
        driver.switch_to_window(driver.window_handles[1])
    time.sleep(3)

    activity_button = driver.find_element_by_link_text('Activity')
    activity_button.click()

    transactions_button = driver.find_element_by_link_text('Transactions')
    transactions_button.click()

    deposit_click = driver.find_element_by_id('chkTransType_0')
    deposit_click.click()
    time.sleep(1)  # WAIT 1 SECOND!

    withdraw_click = driver.find_element_by_id('chkTransType_1')
    withdraw_click.click()
    time.sleep(1)  # WAIT 1 SECOND!

    vendor2user_click = driver.find_element_by_id('chkTransType_4')
    vendor2user_click.click()
    time.sleep(1)  # WAIT 1 SECOND!

    wallet_debit = driver.find_element_by_id('chkTransType_7')
    wallet_debit.click()
    time.sleep(1)  # WAIT 1 SECOND!

    processing_click = driver.find_element_by_id('cbxTransStatus_1')
    pending_click = driver.find_element_by_id('cbxTransStatus_3')
    processing_click.click()
    pending_click.click()
    time.sleep(1)  # WAIT 1 SECONDS!

    start_day = driver.find_element_by_xpath(
        '/html/body/form/div[3]/table/tbody/tr/td[1]/table/tbody/tr[3]/td[2]/table/tbody/tr/td[2]/input[1]'
    )
    start_day.clear()
    start_day.click()
    start_day.send_keys('13/11/2019')
Beispiel #10
0
def get_time():
    for i in range(1, 31):
        time_withdraw = driver.find_elements_by_xpath(
            f"/html/body/div/div/div[2]/div/div/div/div/div/ui-view/div/div/div[2]/div/ubo-tma-table/div/div[2]/table/tbody/tr[{i}]/td[1]/span[2]")
        filtered_time_withdraw.append(time_withdraw[0].text)

    last_kt.append(filtered_time_withdraw[0])
    if len(last_kt) > 1:
        if last_kt[0] in filtered_time_withdraw:
            index_last_kt = filtered_time_withdraw.index(last_kt[0])
            del filtered_time_withdraw[index_last_kt:]
            del filtered_cid[index_last_kt:]
            del last_kt[0]
        else:
            driver.switch_to_window(driver.window_handles[2])
            send_message = driver.find_element_by_xpath(
                "/html/body/div[2]/div/div/div[4]/div/div/footer/div/div/div[1]/div/div[1]")
            send_message.send_keys("NU EXISTA DEPOSIT. CONTROLEAZA MANUAL!")
            send_message.send_keys(Keys.ENTER)
            driver.switch_to_window(driver.window_handles[0])
            del last_kt[0]
    cp10_cid()
Beispiel #11
0
def test_item_of_product_verify(driver):
    driver.get("http://localhost/litecart/public_html/en/")
    driver.implicitly_wait(60)
    duck_crowd = driver.find_elements_by_xpath(
        "//div[@id='box-campaigns']//ul[@class='listing-wrapper products']//li"
    )
    #  нужно сохранить аттрибуты товара для последующей проверки

    num_of_product = []
    link_for_product_page = []
    product_name = []
    product_price = []
    product_price_with_discount = []

    product_price_style_text_decoration = []
    product_price_style_font_size = []
    product_price_with_discount_style_font_weight = []
    product_price_with_discount_style_font_size = []

    i = 0
    for duck in duck_crowd:
        num_of_product.append(i)
        link_for_product_page.append(
            duck.find_element_by_xpath(".//a[@class='link']").get_attribute(
                'href'))
        product_name.append(
            duck.find_element_by_xpath(".//div[@class='name']").text)
        product_price.append(
            duck.find_element_by_xpath(
                ".//div[@class='price-wrapper']/s").text)
        #  проверка на то что скидки может не быть.
        product_price_with_discount.append(
            duck.find_element_by_xpath(
                ".//strong[@class='campaign-price']").text)
        #  работа со стилями
        product_price_style_text_decoration.append(
            duck.find_element_by_xpath("//s[@class='regular-price']").
            value_of_css_property('text-decoration'))
        product_price_style_font_size.append(
            duck.find_element_by_xpath("//s[@class='regular-price']").
            value_of_css_property('font-size'))
        product_price_with_discount_style_font_weight.append(
            duck.find_element_by_xpath("//strong[@class='campaign-price']").
            value_of_css_property('font-weight'))
        product_price_with_discount_style_font_size.append(
            duck.find_element_by_xpath("//strong[@class='campaign-price']").
            value_of_css_property('font-size'))

        print('ELEMENT' + str(i))
        print(product_name)
        print(product_price)
        print(product_price_with_discount)
        print(product_price_style_text_decoration)
        print(product_price_style_font_size)
        print(product_price_with_discount_style_font_weight)
        print(product_price_with_discount_style_font_size)
        i = i + 1

    print(link_for_product_page)
    #  перейдем по ссылке для сравнения каждого товара
    for j in range(len(num_of_product)):
        driver.get(link_for_product_page[j])
        # проведем сравнение
        n_product_name = driver.find_element_by_xpath(
            ".//*[@id='box-product']/div[1]/h1").text
        n_product_price = driver.find_element_by_xpath(
            ".//*[@id='box-product']//div[@class='information']//div["
            "@class='price-wrapper']/s").text
        #  проверка на то что скидки может не быть.
        n_product_price_with_discount = driver.find_element_by_xpath(
            ".//*[@id='box-product']//div["
            "@class='information']//div["
            "@class='price-wrapper']/strong").text
        #  работа со стилями
        n_product_price_style_text_decoration = driver.find_element_by_xpath(
            ".//*[@id='box-product']//div["
            "@class='information']//div["
            "@class='price-wrapper']/s").value_of_css_property(
                'text-decoration')
        n_product_price_style_font_size = driver.find_element_by_xpath(
            ".//*[@id='box-product']//div["
            "@class='information']//div["
            "@class='price-wrapper']/s").value_of_css_property('font-size')
        n_product_price_with_discount_style_font_weight = driver.find_element_by_xpath(
            ".//*[@id='box-product']//div["
            "@class='information']//div["
            "@class='price-wrapper']/strong").value_of_css_property(
                'font-weight')
        n_product_price_with_discount_style_font_size = driver.find_element_by_xpath(
            ".//*[@id='box-product']//div["
            "@class='information']//div["
            "@class='price-wrapper']/strong["
            "@class='campaign-price']").value_of_css_property('font-size')

    print('ELEMENT FROM PRODUCT_PAGE')
    print(n_product_name)

    print(n_product_price)
    print(n_product_price_with_discount)

    print(n_product_price_style_text_decoration)
    print(n_product_price_style_font_size)
    print(n_product_price_with_discount_style_font_weight)
    print(n_product_price_with_discount_style_font_size)

    assert n_product_name == product_name[j]

    assert n_product_price == product_price[j]
    assert n_product_price_with_discount == product_price_with_discount[j]

    assert n_product_price_style_text_decoration == product_price_style_text_decoration[
        j]
    assert n_product_price_style_font_size == product_price_style_font_size[j]
    assert n_product_price_with_discount_style_font_weight == product_price_with_discount_style_font_weight[
        j]
    assert n_product_price_with_discount_style_font_size == product_price_with_discount_style_font_size[
        j]
Beispiel #12
0
from selenium import webdriver
from time import sleep
from login import driver
from selenium.webdriver.support.ui import Select
sleep(2)
driver.find_element_by_xpath('//*[@id="main_left"]/ul/li[8]').click()
sleep(2)
driver.find_element_by_partial_link_text('进入评级').click()
sleep(5)
driver.find_element_by_id('compName').click()
sleep(2)
Select(driver.find_element_by_id("compName")).select_by_value('0K00')
driver.find_element_by_id('custCode').send_keys('深圳前海未来教育科技有限公司')
sleep(2)
driver.find_element_by_xpath(
    '//*[@id="mainContentDiv"]/div[1]/div/ul/li').click()
driver.find_element_by_id('sub1').click()
sleep(3)
driver.find_element_by_id('sub3').click()
driver.find_element_by_xpath(
    '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[3]/td/div/button[1]'
).click()
sleep(2)
driver.find_element_by_xpath(
    '//*[@id="table_details"]/tbody/tr/td[10]/a[2]').click()
Beispiel #13
0
def find_deposit(filtered_trans_type, amount, balance, counter_withdraw):
    if filtered_last_note[-1] == "gh":
        print("gh eklemesi var.")
        approve_withdraw()

    elif filtered_trans_type[-1] == "Deposit" or filtered_trans_type[-1] == "Vendor2User":
        for i in range(len(filtered_trans_type)-1, 0, -1):
            if filtered_trans_type[i-1] == "WalletDebit":
                balance -= float(amount[i-1])
                del amount[-1]
                del filtered_trans_type[-1]
                if balance <= 0:
                    approve_withdraw()
                    break
                if i == 1:
                    decline_withdraw(balance)
                    break

            elif i == 1 and filtered_trans_type[i-1] == "Withdraw":
                decline_withdraw(balance)
                break

            elif 'WalletDebit' not in filtered_trans_type:
                driver.switch_to_window(driver.window_handles[2])
                send_message = driver.find_element_by_xpath(
                    "/html/body/div[2]/div/div/div[4]/div/div/footer/div/div/div[1]/div/div[1]")
                send_message.send_keys(
                    filtered_time_withdraw[-1], " ", filtered_cid[-1], " - ", amount[-1], " ", cek_decline)
                send_message.send_keys(Keys.ENTER)
                amount.clear()
                filtered_trans_type.clear()
                filtered_last_note.clear()
                filtered_number_row.clear()
                del filtered_cid[-1]
                del filtered_time_withdraw[-1]
                driver.switch_to_window(driver.window_handles[0])
                cp10_cid()
                break

    elif counter_withdraw >= 2:                  # If we have 2 withdraws in list -> approve withdraw
        print("2 cekimi var...")
        approve_withdraw()

    elif filtered_trans_type[-1] != "Deposit" or filtered_trans_type[-1] != "Vendor2User":
        driver.execute_script("window.scrollTo(0, 3000)")
        time.sleep(5)

        current_page = driver.find_element_by_xpath(
            f"/html/body/form/div[3]/div[5]/span")
        filtered_current_page.append(current_page.text)

        span = driver.find_element_by_xpath(
            f"/html/body/form/div[3]/div[5]/a[{int(filtered_current_page[-1])+2}]")
        if int(filtered_current_page[-1]) > 5:
            approve_withdraw()
        # if int(filtered_current_page[-1]) >= 11 and int(filtered_current_page[-1]) < 21:
        #     span = driver.find_element_by_xpath(
        #         f"/html/body/form/div[3]/div[5]/a[{int(filtered_current_page[-1])-7}]")
        # elif int(filtered_current_page[-1]) >= 21 and int(filtered_current_page[-1]) < 31:
        #     span = driver.find_element_by_xpath(
        #         f"/html/body/form/div[3]/div[5]/a[{int(filtered_current_page[-1])-17}]")

        span.click()
        filtered_number_row.clear()
        filtered_current_page.clear()
        get_data_from_r5()