added files for automated code submission

This commit is contained in:
Harshit Mahajan 2018-10-03 21:41:41 +05:30
parent fc2a740e97
commit ea7684c1b0
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,2 @@
# Automated Submission
A simple script to submit you code on [https://www.codechef.com] using selenium.

View File

@ -0,0 +1,42 @@
from selenium import webdriver
import getpass
import time
username = "username"
password = getpass.getpass("Password:")
problem = 'TEST'
code = """
#include <iostream>
int main(void) {
char c, d=10;
while(std::cin.get(c) && (c!='2' || d!='4') && std::cout.put(d))
d=c;
}
"""
browser = webdriver.Firefox()
browser.get('https://www.codechef.com')
nameElem = browser.find_element_by_id('edit-name')
nameElem.send_keys(username)
passElem = browser.find_element_by_id('edit-pass')
passElem.send_keys(password)
browser.find_element_by_id('edit-submit').click()
browser.get("https://www.codechef.com/submit/" + problem)
time.sleep(20)
browser.find_element_by_id("edit_area_toggle_checkbox_edit-program").click()
inputElem = browser.find_element_by_id('edit-program')
inputElem.send_keys(code)
browser.find_element_by_id("edit-submit").click()