LaVOZs

The World’s Largest Online Community for Developers

'; javascript - AppleScript click on element with mouseup/dojo - LavOzs.Com

I'm writing a really basic AppleScript app that can clock me in/out everyday in Safari (many reasons why, the app is terrible/I'm stupid). I've gotten all way up to the actual "Clock In" button, which seems to be less of a button and more of an event-based function with mouseups and such.

I've tried pretty much every do javascript .document.getElementBy[X] with ClassName, ID, etc, and also tried variations of .onmouseup(); and .click().

The problem seems to be (me) not knowing which span to try and click on (see screenshot), or how to activate the mouseup before clicking if necessary.

Here's a screenshot of hopefully most of the relevant information. Again, all I'm trying to do is get AppleScript to click on "clock in".

Screenshot of span.timeClockContainer

Outside of those properties, offsetParent, parentNode, and parentElement all read span.timeCLockButtonContainer. There seems to be a lot of meat in the Nodes categories, but I'm not sure if that's relevant.

Here is the main element that I believe contains the info I need:

<span class="timeClockButtonContainer">
               <span data-dojo-type="dijit/_Widget" 
               data-dojo-attach-point="ShiftStartBtn" 
               data-dojo-attach-event="onMouseUp: _onShiftStartMouseUp " 
               data-dojo-props="className: at('rel:', 
               'shiftStartDisabled').direction(at.from).transform(transformers.ShiftStartClass)" 
               id="dijit__Widget_22" 
               widgetid="dijit__Widget_22" 
               class="timeClockButton ShiftStartNormal ">
                        </span>
               <span data-dojo-type="Framework/UI/mvc/Output" 
               data-dojo-props="value: localize('lblESSShiftStartButton'), className: at('rel:', 
               'shiftStartDisabled').direction(at.from).transform(transformers.ButtonClass)" 
               class="ClockButtonTextEnabled" 
               id="Output_90" widgetid="Output_90">In</span>
</span> 

The second span only refers to the text underneath the button. But wanted to be thorough and include it.

Of course, I'm aware that a regular old "System Event" click in AppleScript will work, but I intend to try and make this run in the background at some point.

Related
Why don't self-closing script elements work?
How do I detect a click outside an element?
How do I check if an element is hidden in jQuery?
Event binding on dynamically created elements?
Retrieve the position (X,Y) of an HTML element
How can I select an element by name with jQuery?
How to move an element into another element?
How do I remove a particular element from an array in JavaScript?
jQuery scroll to element