modularization and addition of Locals Specific Functions

main
Yuriy 5 months ago
parent 8a532ac787
commit 5671242faf

@ -0,0 +1,50 @@
; Iterate over Locals posts on the home page until found post with title
; ------------------------------------------------
GrabLocalsPostURLUsingTitle(PostTitle){
Loop, 10 {
Message = Checking Post %A_index% on page for Post Titled`n%PostTitle%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
ToolTip, %A_Index%
; first two items can be skipped.
; new Post box and Create other forms of posts box
if(A_index < 3)
Continue
; Xpath for each post box on the main page
Xpath = //body/div/div/div/div/div/div[1]/div[%A_Index%]
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
if(InStr(ElementInnerText, PostTitle)){
Message = Found Post Title in Element Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Pull Out the Post URL from the OuterHTML using RegEx
regexMatch := RegExMatch(ElementOuterHTML, "data-post-url=""([^""]+)""", match)
if (regexMatch)
{
PostURL := match1
Message = URL Pulled out from OuterHTML: %PostURL%
Return PostURL
}
else {
Message = Failed to Pull out URL from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}
}
}
Message = Failed to find New Post in the first 10 posts
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}

@ -820,6 +820,38 @@ SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab
}
GetHTMLValueFromXpathOuterHTML(XPATH, HTMLElementName){
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Match string between quotes following the HTMLELEMENTNAME
RegexStatement = %HTMLElementName%="([^"]+)"
; regexMatch := RegExMatch(ElementOuterHTML, "value=""([^""]+)""", match)
regexMatch := RegExMatch(ElementOuterHTML, RegexStatement, match)
if (regexMatch)
{
ElementValue := match1
; Msgbox % "PostURL: " PostURL
; Message = URL Pulled out from OuterHTML: %PostURL%
Return ElementValue
}
else {
Message = Failed to Pull out value from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed"
}
}
;---\Selenium---
;------------------------------------------------

Loading…
Cancel
Save