Monday, July 8, 2019

Program to Open Calculator and read file for the Inputs

Program to Open Calculator and read file for the Inputs
Using Selenium Python

........ calculator_using_readfile.py ......................


import subprocess
import pyautogui, time

#Read File
f = open("E:\\Mano\\Python Selenium\\calculator_input.txt", "r")
input1 = f.readline().strip("\n\r")
operator1 = f.readline().strip("\n\r")
input2 = f.readline().strip("\n\r")
operator2 = f.readline().strip("\n\r")

#Open Calculator
subprocess.Popen('C:\\Windows\\System32\\calc.exe')
time.sleep(5)

#Value 5 pressed
pyautogui.press(input1)

#Operator x  pressed
pyautogui.press(operator1)

#Value 6 pressed
pyautogui.press(input2)

#Operator ENTER pressed
pyautogui.press(operator2)

## Total 5 x 6 => 30

........ calculator_input.txt ......................

#Below inputs in separate line
5
*
6
enter

No comments:

Post a Comment

Popular Posts