Advertisement
Josif_tepe

Untitled

Apr 6th, 2025
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. import time
  2. import re
  3. from selenium import webdriver
  4. from selenium.webdriver.common.by import By
  5.  
  6. driver = webdriver.Chrome()
  7. driver.get('https://mendo.mk')
  8. time.sleep(5)
  9.  
  10. username_input_label = driver.find_element(By.XPATH, '//*[@id="username"]')
  11. time.sleep(2)
  12. username_input_label.send_keys("Selenium")
  13. time.sleep(2)
  14.  
  15. password_input_label = driver.find_element(By.XPATH, '//*[@id="password"]')
  16. time.sleep(2)
  17. password_input_label.send_keys("selenium")
  18.  
  19. button_to_login = driver.find_element(By.XPATH, '//*[@id="LoginForm"]/fieldset/p[4]/input')
  20. button_to_login.click()
  21. time.sleep(2)
  22.  
  23. id_problem = 1
  24. url = f'https://mendo.mk/Task.do?id={id_problem}'
  25. driver.get(url)
  26. driver.execute_script('window.scrollTo(0, document.body.scrollHeight - 800);')
  27. time.sleep(2)
  28.  
  29. solution_input = driver.find_element(By.XPATH, '//*[@id="solutionCode"]')
  30.  
  31. solution_code = ''
  32. with open('main.txt', 'r') as f:
  33.     solution_code = f.read()
  34.  
  35. solution_input.send_keys(solution_code)
  36.  
  37. submit_code_button = driver.find_element(By.XPATH, '//*[@id="SolutionForm"]/fieldset/p[4]/input')
  38. submit_code_button.click()
  39. time.sleep(10)
  40.  
  41. html = driver.page_source
  42.  
  43.  
  44. correct_answers = re.findall('Correct', html)
  45. wrong_asnwers = re.findall('Wrong', html)
  46. timeout_answers = re.findall("Time Limit ", html)
  47. runtime_answers = re.findall("Runtime", html)
  48.  
  49. print(f"Correct answers: {len(correct_answers)}")
  50. print(f"Wrong answers: {len(wrong_asnwers)}")
  51. print(f"Timeout answers: {len(timeout_answers)}")
  52. print(f"Runtime answers: {len(runtime_answers)}")
  53.  
  54.  
  55.  
  56.  
  57. time.sleep(100)
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement