cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Programmatic checkbox interaction

jpray
1-Newbie

Programmatic checkbox interaction

I’m working on a page scraping routine to go into Windchill after information not programmatically available by more straightforward means (like task URLs).  This is implemented in VBA and browsing through IE11 -- I can give more details on exactly how if needed, but I don’t think it really impacts my question -- the long story short is that it’s all been more or less straightforward, with the exception of programmatically interacting with Windchill’s checkboxes, because I can’t find them!

All of the buttons, textboxes, and other input objects on a typical page in Windchill seem to be accessible as expected and are visible in the page’s document.innerHTML source, but not the checkboxes -- they don’t seem to be in, or associated with, the <DIV>s in which they appear, or impacted by any other input objects I can dig out of the innerHTML and programmatically click, set checked = true, etc.

All my program needs to do is uncheck the checkbox for one workflow and check the checkbox for a different workflow so that the right process history table will load onto a record.  Can anyone offer any insight on where the checkboxes actually are in the page code, what they’re called, what generates them, what reacts to them being checked or unchecked, etc.?  This has been like trying to solve a puzzle I can’t find in the first place -- I don’t need a complete solution, I (hope I) just need someone to show me where it is.


Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jpray
1-Newbie
(To:jpray)

For the benefit of anyone else looking for a solution to this issue, after investigating Windchill's checkboxes thoroughly, I ended up building a function to obtain the element locations and use the Windows API to foreground the browser and generate cursor clicks over them -- this worked.  The checkboxes are implemented (so far as I could determine) in a way that, whether by accident or design, makes them unresponsive to any mouse events that aren't generated from the actual cursor.  In short, if the mouse pointer isn't physically in the browser window and causing the clicks, the checkboxes ignore the input.

View solution in original post

8 REPLIES 8
tstacy
1-Newbie
(To:jpray)

Are you talking about a Workflow Task page or a wizard page like for Create or Edit?

jpray
1-Newbie
(To:tstacy)

A Workflow task page (I'm assuming -- since it's not a wizard page).  More specifically, it's the Process tab of a Change record; the checkboxes I need to find to interact with are in the rows of the Routing/Process History table, and they control what shows up in the Process Status table.  There's also a "Select All" checkbox in the Routing/Process History table's heading row, but that's not so useful for my purposes since the Process Status table only populates when one checkbox is checked.  Does that help?

tstacy
1-Newbie
(To:jpray)

Each of the tables on the Process tab are constructed using their own builders or JSPs.  Some are even separate JSPs displayed together. The names of the tables and the elements on that table are auto-generated so they have weird names. Have you tried using the F12 function on Internet Explorer to open the DOM Explorer?  It will show you everything about an element.

Hopefully you can see the snippet I pasted. This might help you track down the items you are looking for.

jpray
1-Newbie
(To:tstacy)

Stacy, thanks for the response!

Yes, I was able to get this far using the DOM explorer.  Finding those x-grid3-row-checker divs programmatically is no problem, but I couldn't find any way to interact with them or their child objects (via .click, .select, or set Checked = true) that made the checkboxes become checked.  I even found them in VBA and explored every available property for them and their children and parents ad nauseum... the header td where the Select-All checkbox appears has one child div that will actually pop a sort menu if VBA .clicks it -- but it's what you would get if you could click under the checkbox.


Unless I'm missing something, I think those divs aren't actually the checkboxes, but maybe more like anchors for them?  If there is something I'm missing and they (or something in them) will respond to the right kind of input, that would be great, but as you can see in your screencap, they don't seem to contain any HTML input items, checkbox-type or otherwise.  In the style pane, I was able to track down a background checkbox gif that shows checked and unchecked versions of the checkbox, but that gif's link doesn't actually appear in the innerHTML (that is, the code you see in the DOM explorer).  That, and the fact that the checkboxes don't react when moused over (only when clicked), makes me suspicious that the divs (and maybe the innerHTML, period) are the wrong place to look.


There is, elsewhere in the innerHTML and nowhere near the rows containing the checkboxes, a <SPAN id=checkboxesFor_processHistoryTableId style="DISPLAY: none"> ... </SPAN> that contains an <INPUT> of type=checkbox for each checked checkbox I'm interested in.  However, telling these to be checked or unchecked (or changing their ids, or adding or removing them from the SPAN) doesn't seem to do anything, and they're only there if the boxes are already checked, so it seems less like they control those checkboxes and more like they're just reporting the current conditions.


So -- that's a lot more detail on what I've tried that hasn't worked, anyway.

RandyJones
19-Tanzanite
(To:jpray)

You can also rmb over most elements and go to "Inspect Element" with both FireFox and IE. If you download FireBug for FireFox you can also rmb and select "Inspect Element with FireBug". These menu selections will take you right to the element "code" .

You should have a look at jquery which is included in Windchill. Jquery works great for the kind of thing you are attempting to do.

https://jquery.com/

Have you tried right-clicking and inspecting element with the checkboxes?  Because I have, and it's like they're not there.  I have not tried with FireBug and might have trouble getting that at work; if you have it and can see if you can actually inspect the checkboxes, I'd be very interested to find out what you get.

Otherwise, though, this is the heart of my whole problem: the checkboxes aren't accessible by any means I know of for getting at the elements of a webpage.

As far as jquery goes, I've tinkered with it for personal website design, but haven't tried it for this, no.  Do you bring it up to suggest I switch languages, or is there some specific capability of jquery for finding things like this that you had in mind?  Switching languages for the whole implementation isn't really an option at this point, since this is just one part of a much larger tool that's otherwise working fine.

jpray
1-Newbie
(To:jpray)

For the benefit of anyone else looking for a solution to this issue, after investigating Windchill's checkboxes thoroughly, I ended up building a function to obtain the element locations and use the Windows API to foreground the browser and generate cursor clicks over them -- this worked.  The checkboxes are implemented (so far as I could determine) in a way that, whether by accident or design, makes them unresponsive to any mouse events that aren't generated from the actual cursor.  In short, if the mouse pointer isn't physically in the browser window and causing the clicks, the checkboxes ignore the input.

awitzke
1-Newbie
(To:jpray)

Thanks for posting this. I am having the same issues you are and may have to resort to mouse clicks.

I'm curious how you were able to find the coordinates for the checkboxes you are interested in clicking.  I can find the object in the DOM for the row in the table that I want, but it could require scrolling the table for that line to be in view.  I think I can get through it based on how I found coordinates of other objects to click on, but it might be a pain...

Anyway, please let me know if you ever found a better solution to using mouse clicks.

Top Tags