dgendrud Posted March 8, 2023 Posted March 8, 2023 I am trying to search for an element, starting at the prior element that I just found. It seems I should be using the $sStartNodeID, but can't seem to get it to work. I was assuming that what should be used for the $sStartNodeID would be the returned value from the prior element search. This may not be correct, but cannot find the answer via any forum or google searches. Just need some direction on where to find an example or info on this please. Thanks
Danp2 Posted March 8, 2023 Posted March 8, 2023 I believe that you are correct in the usage of $sStartNodeID. We will need more details in order to assist you. Exactly what isn't working as expected? What errors are logged in the console? Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted March 8, 2023 Author Posted March 8, 2023 Looking for multiple instances of tagname "a" that come after the "$aFirstTkr" element. Statement does not return any element(s). Attached: Script & last part of console. ICON ACCESS tst.au3 console.txt
Danp2 Posted March 8, 2023 Posted March 8, 2023 Quote $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByTagName, "a", $aFirstTkr, "TRUE", "FALSE") The last two parameters shouldn't be in quotes. Otherwise, this looks ok. Try making those changes and then retest. Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted March 8, 2023 Author Posted March 8, 2023 Taking off the "" did not make any difference, however, I think I now have a clue as to why no elements are found with tagname "a". When the script stops after the command fails to find any elements, the URL is still up. When I go to tools and inspect the starting element, and then look at the HTML below (where it should be finding elements with tagname "a", there are none showing. When I use the dropdown arrows on the left the elements I'm looking for become visible. Seems only "visible" elements are found. Is there a way to force all the page HTML to be visible?
Danp2 Posted March 9, 2023 Posted March 9, 2023 1 hour ago, dgendrud said: Taking off the "" did not make any difference Technically, it did by solving the problem where _WD_FindElement was returning the error Unknown Command. Quote When I use the dropdown arrows on the left the elements I'm looking for become visible. Seems only "visible" elements are found. I'm not sure which dropdown arrows you are referring to here. Please clarify. Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted March 9, 2023 Author Posted March 9, 2023 Yes, solved the Unknown cmd issue, now just a no match issue. I suspect the no match is because the html that exists on the page, just below the "$sStartNodeID element" , is not expanded so the elements I am searching for are not visible. When I use the Firefox web developer tool and inspect I can only see the "row elements" I can use the down arrows on the left of the html elements to show the elements I am searching for. Cannot find any command to solve this yet. Maybe, I need to use the _WD_GetSource($sSession) command and search that? Maybe there is a more straightforward way? I'm working it, but any guidance is appreciated, Thanks
Danp2 Posted March 9, 2023 Posted March 9, 2023 @dgendrudLet's try this another way because your last post didn't help me understand the situation any better. I've run your script and also examined the website in the browser's Dev Tools. This code -- ;Get the link element - There appears there is only one element due to the XPath locator used (link by text did not seem to work) ;This XPath find now seems to work and return a value Local $aFirstTkr = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/main/article/div/div[1]/table/tbody[1]/tr[1]/td[1]/a", DEFAULT,DEFAULT) finds the first link in the table's symbol column. This was "ADM" for me. BTW, this xpath could be shorted to "//table/tbody/tr/td/a". Is this the correct element that you are trying to locate? Since it doesn't have any children, it can't be used as the starting node in subsequent lookups. I'm still not clear which down arrows you are talking about. This is what the top section of the table looks like for me -- Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted March 9, 2023 Author Posted March 9, 2023 OK, thanks again. These comments help, I'm going to work this some more. This URL page has about 40 stock symbols. I am trying to access them all and get them into an array. I'm thinking of looking at some of the Frame commands.
Danp2 Posted March 9, 2023 Posted March 9, 2023 16 minutes ago, dgendrud said: I'm thinking of looking at some of the Frame commands. Why? Those are only beneficial if there are frames involved. Quote This URL page has about 40 stock symbols. I am trying to access them all and get them into an array. There are multiple ways to achieve this. You could use _WD_GetTable, which should produce an array containing the entire table's contents. You could also do something like this (untested) -- Local $aLinks = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//table/tbody/tr/td/a", Default, True) Local $iCount = UBound($aLinks) Local $aSymbols[$iCount] For $iIndex = 0 To $iCount - 1 $aSymbols[$iIndex] = _WD_ElementAction($sSession, $aLinks[$iIndex], "Text") Next _ArrayDisplay($aSymbols) This could also be accomplished with a single call to _WD_ExecuteScript to gather the desired information using Javascript. Latest Webdriver UDF Release Webdriver Wiki FAQs
dgendrud Posted March 9, 2023 Author Posted March 9, 2023 Many thanks! I'll try all these - I really need to learn this!
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