예제 #1
0
    def test_second_site(self):
        self.browser = main.get_connection(
            'http://suninjuly.github.io/registration2.html')
        self.fill_fields()

        button = self.browser.find_element_by_css_selector("button.btn")
        button.click()

        time.sleep(2)

        result = self.browser.find_element_by_tag_name("h1").text
        self.assertEqual(result, "Поздравляем! Вы успешно зарегистировались!",
                         "RegError")
예제 #2
0
from selenium.webdriver.support.select import Select

import main
from selenium.webdriver.common.by import *

browser = main.get_connection('http://suninjuly.github.io/selects1.html')
first_num = browser.find_element(By.CSS_SELECTOR, 'span#num1').text
second_num = browser.find_element(By.CSS_SELECTOR, 'span#num2').text

num_sum = int(first_num) + int(second_num)

select = Select(browser.find_element(By.CSS_SELECTOR, "select.custom-select"))
select.select_by_value(str(num_sum))

submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn')
submit_button.click()
예제 #3
0
import os

from selenium.webdriver.common.by import *

import main

browser = main.get_connection('http://suninjuly.github.io/file_input.html')

input_first_name = browser.find_element(By.CSS_SELECTOR,
                                        'input[name=firstname]')
input_first_name.send_keys("Ivan")

input_second_name = browser.find_element(By.CSS_SELECTOR,
                                         'input[name=lastname]')
input_second_name.send_keys("Petrov")

input_email = browser.find_element(By.CSS_SELECTOR, 'input[name=email]')
input_email.send_keys("*****@*****.**")

input_file = browser.find_element(By.CSS_SELECTOR, 'input#file')
file = open('input_file.txt', 'w').close()
current_dir = os.path.abspath(os.path.dirname(__file__))
file_path = os.path.join(current_dir, 'input_file.txt')

input_file.send_keys(file_path)

submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn')
browser.execute_script("return arguments[0].scrollIntoView(true)",
                       submit_button)
submit_button.click()
from datetime import datetime

parser = argparse.ArgumentParser()

parser.add_argument("-u", "--username", help="Login użytkownika")
parser.add_argument("-p", "--password", help="Hasło")
parser.add_argument("-l",
                    "--list",
                    action="store_true",
                    help="Lista wszystkich twoich komunikatów")
parser.add_argument("-t", "--to", help="Mail odbiorcy")
parser.add_argument("-s", "--send", help="Treść komunikatu do wysłania")

args = parser.parse_args()

conn = get_connection()

if conn:
    cursor = conn.cursor()

    # Lista komunikatów
    if args.list:
        if args.username and args.password:
            u = User.load_user_by_username(cursor, args.username)
            if u and check_password(args.password, u.hashed_password):
                m = Message.load_all_messages_for_user_by_username(
                    cursor, args.username)
                for message in m:
                    print(message.creation_date, message.from_id, message.text)
            else:
                raise Exception("Błąd użytkownika lub hasła.")
예제 #5
0
import main

browser = main.get_connection('http://suninjuly.github.io/cats.html')
browser.find_element_by_id("button")
예제 #6
0
from selenium.webdriver.common.by import *

import main

browser = main.get_connection('http://suninjuly.github.io/alert_accept.html ')

submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn')
browser.execute_script("return arguments[0].scrollIntoView(true)", submit_button)
submit_button.click()

confirm = browser.switch_to.alert
confirm.accept()


x_element = browser.find_element(By.CSS_SELECTOR, '.form-group .nowrap#input_value')
calc_result = main.calc(x_element.text)

input_answer_field = browser.find_element(By.CSS_SELECTOR, 'input#answer')
input_answer_field.send_keys(calc_result)

submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn')
browser.execute_script("return arguments[0].scrollIntoView(true)", submit_button)
submit_button.click()
예제 #7
0
# waiting

import time


from selenium.webdriver.common.by import *
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

import main

browser = main.get_connection('http://suninjuly.github.io/explicit_wait2.html')


text = WebDriverWait(browser, 12).until(EC.text_to_be_present_in_element((By.ID, "price"), "10000"))

# click redirect button
submit_button = browser.find_element(By.CSS_SELECTOR, 'button#book')
browser.execute_script("return arguments[0].scrollIntoView(true)", submit_button)
submit_button.click()


# calc answer
x_element = browser.find_element(By.CSS_SELECTOR, '.form-group .nowrap#input_value')
calc_result = main.calc(x_element.text)

input_answer_field = browser.find_element(By.CSS_SELECTOR, 'input#answer')
input_answer_field.send_keys(calc_result)

submit_button = browser.find_element(By.CSS_SELECTOR, 'button#solve')
browser.execute_script("return arguments[0].scrollIntoView(true)", submit_button)
예제 #8
0
from selenium.webdriver.common.by import *

import main

browser = main.get_connection('http://suninjuly.github.io/execute_script.html')

x_element = browser.find_element(By.CSS_SELECTOR,
                                 '.form-group .nowrap#input_value')
calc_result = main.calc(x_element.text)

input_answer_field = browser.find_element(By.CSS_SELECTOR, 'input#answer')
input_answer_field.send_keys(calc_result)

input_robot_checkbox = browser.find_element(By.CSS_SELECTOR,
                                            'input#robotCheckbox')
input_robot_checkbox.click()

input_robot_radio = browser.find_element(By.CSS_SELECTOR, 'input#robotsRule')
browser.execute_script("return arguments[0].scrollIntoView(true)",
                       input_robot_radio)
input_robot_radio.click()

submit_button = browser.find_element(By.CSS_SELECTOR, 'button.btn')
browser.execute_script("return arguments[0].scrollIntoView(true)",
                       submit_button)
submit_button.click()