LOUNGE all new asksnapzu ideasforsnapzu newtribes interesting pics videos funny technology science technews gaming health history worldnews business web research entertainment food living internet socialmedia mobile space sports photography nature animals movies culture travel television finance music celebrities gadgets environment usa crime politics law money justice psychology security cars wtf art google books lifetips bigbrother women apple kids recipes whoa military privacy education facebook medicine computing wildlife design war drugs middleeast diet toplists economy fail violence humor africa microsoft parenting dogs canada neuroscience architecture religion advertising infographics sex journalism disaster software aviation relationships energy booze life japan ukraine newmovies nsa cannabis name Name of the tribe humanrights nasa cute weather gifs discoveries cops futurism football earth dataviz pets guns entrepreneurship fitness android extremeweather fashion insects india northamerica
+2
Save

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
import time
#driver = webdriver.Chrome('C:\chromedriver.exe')
driver = webdriver.Ie('C:\IEDriverServer.exe')
driver.get('http://time.system-integrations.com/')

try:
    username = driver.find_element_by_name('username')
    username.send_keys('USERNAME')

    password = driver.find_element_by_name('Password')
    password.send_keys('PASSWORD')

    code = driver.find_element_by_name('CompanyCode')
    code.send_keys('CODE')

    login = driver.find_element_by_name('Login')
    login.click()

    inoutButton = driver.find_element_by_xpath("//img[contains(@src, 'InOut.gif')]/parent::a")
    inoutButton.click()

except:
    print('Nope')

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!!!

3 years ago by sixstorm with 1 comments

Join the Discussion

  • Auto Tier
  • All
  • 1
  • 2
  • 3
Post Comment
  • tefids
    +1

    I am not familiar with Selenium, but I have done some IE automation using the COM interface from VBA (yuck :( ). Anyway, one issue I ran into is that the COM functions for finding tags will not find elements that are in iframes. You first have to get a reference to the iframe, and then run the search function again on the iframe. Perhaps you are running into something similar?