Selenium and a Time Clock Website
EDIT: I figured this out by using a mix of Selenium and PYAutoGUI. Basically where Selenium fails, PYAutoGUI will sweep in and save the day. I now have a sweet setup where I swipe my phone over a NFC tag, it sends a message to EventGhost that then triggers this script. A lot easier than logging into a stupid website and clocking in/out!!!
I posted this to Reddit but didn't get but one response. Hoping to find someone here who has a little experience with Selenium.
I'm trying to automate my daily clock in/out via Python and Selenium. I currently have the web browser (IE) opening, all input going in just fine and even the log on process. When I get to the next screen, I'm having a hard time finding the "Clock In/Out" button element. This button is supposed to open a small pop up window with some clock in options, then I can click Submit when complete.
Here is the HTML code of the button:
<a href="/qqest/time/timecard.asp" onclick = "window.open('/qqest/Time/timePunch.asp?punchtype=clockinout&ActiveEmployeeID=149','popuptime','scrollbars=yes,screenX=0,screenY=0,left='+gfnGetWidth(410)+', top='+gfnGetHeight(435)+', width=410, height=435, resizable=yes');"><img src='/qqest/images/buttons/InOut.gif' border=0 hspace=3 onmouseover="this.src='/qqest/images/Buttons/InOut-H.gif';" onmouseout="this.src='/qqest/images/Buttons/InOut.gif';" alt="In/Out"></a>
My Python Script:
from selenium import webdriver
#driver = webdriver.Chrome('C:\chromedriver.exe')
driver = webdriver.Ie('C:\IEDriverServer.exe')
username = driver.find_element_by_name('username')
password = driver.find_element_by_name('Password')
code = driver.find_element_by_name('CompanyCode')
login = driver.find_element_by_name('Login')
inoutButton = driver.find_element_by_xpath("//img[contains(@src, 'InOut.gif')]/parent::a")
I've tried to find this element by HREF and IMG, but it's always a no go (hence I get the "nope" in the Python console). Is there a better way to do this? I've started to possibly add in PyAutoGUI to simulate mouse clicks but I'd rather do it the Selenium way if possible. Help!!!