How to extract/get the URL from a Button/Link in Chrome using outerHTML in Autohotkey? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Sabestian Caine
Posts: 350
Joined: 12 Apr 2015, 03:53

How to extract/get the URL from a Button/Link in Chrome using outerHTML in Autohotkey?

22 Dec 2018, 13:48

I am using Selenium to automate Google Chrome. Suppose I want to extract the URL of this link (as shown in red box)-

Image

For this I am trying to use these codes-

Code: Select all

f1::
driver := ChromeGet()
MsgBox % driver.findElementByClass("forumtitle").Attribute("outerHTML") 
return
 
ChromeGet(IP_Port := "127.0.0.1:9222") {
 driver := ComObjCreate("Selenium.ChromeDriver")
 driver.SetCapability("debuggerAddress", IP_Port)
 driver.Start()
 return driver
}

When I run these codes it shows all the values of outer HTML like this-

Image


On the other hand, I want only the URL of this link which is ./viewforum.php?f=76


Please tell me how can I extract only the URL form specific buttons or Links from a webpage?

I tried to use FindElementByXpath also like this-

Code: Select all

f1::
driver := ChromeGet()
MsgBox % driver.findElementByxpath("//*[@id='page-body']/div[4]/div/ul[2]/li[1]/dl/dt/div/a[1]").Attribute("outerHTML")
return
 
ChromeGet(IP_Port := "127.0.0.1:9222") {
 driver := ComObjCreate("Selenium.ChromeDriver")
 driver.SetCapability("debuggerAddress", IP_Port)
 driver.Start()
 return driver
}
But the above codes are also providing same result as former codes are providing.

Please help me. Thanks..
I don't normally code as I don't code normally.
YOU do what YOU want, but happens what HE wants.
YOU do what HE wants, will happen what YOU want.
User avatar
Sabestian Caine
Posts: 350
Joined: 12 Apr 2015, 03:53

Re: How to extract/get the URL from a Button/Link in Chrome using outerHTML in Autohotkey?  Topic is solved

23 Dec 2018, 06:33

Problem solved!!!

it is working-

Code: Select all

MsgBox % driver.findElementsByClass("forumtitle").item[1].Attribute("href") 

Thanks a lot..
I don't normally code as I don't code normally.
YOU do what YOU want, but happens what HE wants.
YOU do what HE wants, will happen what YOU want.

Return to “Ask For Help”

Who is online

Users browsing this forum: electrone77, MannyKSoSo, scriptor2016, sinkfaze, SOTE and 174 guests