Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import re
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- driver = webdriver.Chrome()
- driver.get('https://mendo.mk')
- time.sleep(5)
- username_input_label = driver.find_element(By.XPATH, '//*[@id="username"]')
- time.sleep(2)
- username_input_label.send_keys("Selenium")
- time.sleep(2)
- password_input_label = driver.find_element(By.XPATH, '//*[@id="password"]')
- time.sleep(2)
- password_input_label.send_keys("selenium")
- button_to_login = driver.find_element(By.XPATH, '//*[@id="LoginForm"]/fieldset/p[4]/input')
- button_to_login.click()
- time.sleep(2)
- id_problem = 1
- url = f'https://mendo.mk/Task.do?id={id_problem}'
- driver.get(url)
- driver.execute_script('window.scrollTo(0, document.body.scrollHeight - 800);')
- time.sleep(2)
- solution_input = driver.find_element(By.XPATH, '//*[@id="solutionCode"]')
- solution_code = ''
- with open('main.txt', 'r') as f:
- solution_code = f.read()
- solution_input.send_keys(solution_code)
- submit_code_button = driver.find_element(By.XPATH, '//*[@id="SolutionForm"]/fieldset/p[4]/input')
- submit_code_button.click()
- time.sleep(10)
- html = driver.page_source
- correct_answers = re.findall('Correct', html)
- wrong_asnwers = re.findall('Wrong', html)
- timeout_answers = re.findall("Time Limit ", html)
- runtime_answers = re.findall("Runtime", html)
- print(f"Correct answers: {len(correct_answers)}")
- print(f"Wrong answers: {len(wrong_asnwers)}")
- print(f"Timeout answers: {len(timeout_answers)}")
- print(f"Runtime answers: {len(runtime_answers)}")
- time.sleep(100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement