CaptainBeardsEyesBeard Posted September 7, 2020 Share Posted September 7, 2020 Hi I'm trying to click on a table link for the below Is this the correct way to do it So I used this For loop to lop through and click Query _IELoadWait($oIE) ;Search Td tags for query ConsoleWrite(@CRLF & "Starting for loop for TDs to find a payment with Query.") $Tds = _IETagNameGetCollection($oIE, "td") Sleep(4000) If IsObj($Tds) Then For $Td In $Tds If $Td.getAttribute("value") = "Query" Then MsgBox(64, ' TD Found', 'TD found with value: ' & $Td.getAttribute("value"), 2) _IEAction($Td, 'click') ConsoleWrite(@CRLF & "Clicking Table item") ExitLoop EndIf Next EndIf However my output on Console is so it's not hitting the table. as it doesn't use the ConsoleWrite bit on "Clicking Table Item" Starting for loop for TDs to find a payment with Query.>Exit code: 0 Time: 31.86 Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted September 7, 2020 Author Share Posted September 7, 2020 Also I'm able to click by ID ConsoleWrite(@CRLF & "Clicking using ID") $TableID= _IEGetObjById($oIE, "ctl00_MPH_ctlPaymentFileLineListing_PaymentFileLineListItem566917_ctlHyperLink") _IEAction($TableID, "click") So I'm wondering if there is a way to return the ID of the table by searching the table for Query which I can then use for an IE_Action click Link to comment Share on other sites More sharing options...
Danp2 Posted September 7, 2020 Share Posted September 7, 2020 If you examine a TD element in the browser's Developer Tools (use Chrome or Firefox), you'll see that it doesn't have a "value" attribute. You need to use either textContent or innerText instead. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted September 7, 2020 Author Share Posted September 7, 2020 Thanks I gave that a try with textcontent and innertext but still not hitting the ConsoleWrite line If IsObj($Tds) Then For $Td In $Tds If $Td.getAttribute("textcontent") = "Query" Then MsgBox(64, ' TD Found', 'TD found with value: ' & $Td.getAttribute("value"), 2) _IEAction($Td, 'click') ConsoleWrite(@CRLF & "Clicking Table item") ExitLoop EndIf Next EndIf Link to comment Share on other sites More sharing options...
Danp2 Posted September 7, 2020 Share Posted September 7, 2020 @CaptainBeardsEyesBeard Notice that I spelled it like textContent, not textcontent. Try again with the proper case and it should work. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted September 7, 2020 Author Share Posted September 7, 2020 I tried ensuring the case matched Quote ;Search Td tags for query ConsoleWrite(@CRLF & "Starting for loop for TDs to find a payment with Query.") $Tds = _IETagNameGetCollection($oIE, "td") Sleep(4000) If IsObj($Tds) Then ConsoleWrite(@CRLF & "$Tds is a Obj") For $Td In $Tds If $Td.getAttribute("innerText") = "Query" Then MsgBox(64, ' TD Found', 'TD found with value: ' & $Td.getAttribute("innerText"), 2) _IEAction($Td, 'click') ConsoleWrite(@CRLF & "Clicking Table item") ExitLoop EndIf Next EndIf ConsoleWrite(@CRLF & "Testing loop via links") $colLinks = _IELinkGetCollection($oIE) For $oLink in $colLinks If String($oLink.textContent) = "Query" Then ConsoleWrite(@CRLF & "Found query") _IEAction($oLink, "click") ExitLoop EndIf Next However I got the following on console output Starting for loop for TDs to find a payment with Query. $Tds is a Obj Testing loop via links>Exit code: 0 Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted September 7, 2020 Author Share Posted September 7, 2020 In fact I managed to get the following console output using ConsoleWrite(@CRLF & "Testing loop via links") $colLinks = _IETagNameGetCollection($oIE, "td") For $oLink in $colLinks If String($oLink.textContent) = "Query" Then ConsoleWrite(@CRLF & "Found query") _IEAction($oLink, "click") ExitLoop EndIf Next Testing loop via links Found query>Exit code: 0 Time: 43.13 However I suspect it is finding the first mention of query Is it possible to search only a table using the table class or table id? Link to comment Share on other sites More sharing options...
Danp2 Posted September 7, 2020 Share Posted September 7, 2020 Have you tried logging each found TD's contents to the Scite console? That way you can get a handle on why your current code isn't working as expected. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted September 7, 2020 Author Share Posted September 7, 2020 5 minutes ago, Danp2 said: Have you tried logging each found TD's contents to the Scite console? That way you can get a handle on why your current code isn't working as expected. Thanks I tried this on a unique phrase and it clicked the link correctly My problem is I want to click an item in the table that is a query but query is mentioned in a few other tables. Is it possible to only search a table by class or ID rather than a full collection? Link to comment Share on other sites More sharing options...
Danp2 Posted September 7, 2020 Share Posted September 7, 2020 4 minutes ago, CaptainBeardsEyesBeard said: Is it possible to only search a table by class or ID rather than a full collection? Yes. Instead of passing $oIE to _IETagNameGetCollection, you can pass a reference to another element. For example -- $oLink = _IEGetObjById($oIE, "ctl00_MPH_ctlPaymentFileLineListing_PaymentFileLineListItem566917_ctlHyperLink") $oTDs = _IETagNameGetCollection($oLink, "td") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now