import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import codecs
import re
import os.path #for file opening in a good folder







inputfile = codecs.open(os.path.dirname(__file__) + "input.txt", encoding='utf-8')

text=inputfile.read()
inputfile.close()
 


lines=re.compile("\n",re.UNICODE).split(text)


driver = webdriver.Chrome()  # Optional argument, if not specified will search path.

translatedlines=[]

for line in lines:
     driver.get('http://taranevis.ir/');
     actions = ActionChains(driver);
     actions.send_keys(line);
     actions.perform();
     time.sleep(5);
     currenttext = driver.find_element_by_class_name('res').text;
     translatedlines.append(currenttext)
     print(currenttext)

outputfile = codecs.open(os.path.dirname(__file__) + "output.txt", 'w', encoding='utf-8')

text='\n'.join(translatedlines)

outputfile.write(text)
outputfile.close()


driver.quit()
