Simulate a click on a document

Simulate a click on a document

Postby Natter » Thu Mar 28, 2019 9:16 am

Hi !

Open IE as an Activex and load a page with a map. I need to simulate a click on this page at the point where the mouse cursor is. How can I do that ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Simulate a click on a document

Postby Horizon » Thu Mar 28, 2019 4:43 pm

+1
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Simulate a click on a document

Postby Silvio.Falconi » Thu Mar 28, 2019 5:52 pm

oWnd:Click()
oWnd is the map
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Simulate a click on a document

Postby Natter » Fri Mar 29, 2019 5:08 am

How can I get this "oWnd is the map" ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Simulate a click on a document

Postby Silvio.Falconi » Fri Mar 29, 2019 9:30 am

oWnd is the object of the page where you open the activex
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Simulate a click on a document

Postby Natter » Fri Mar 29, 2019 10:03 am

Thanks. I usually just used a DOM
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Simulate a click on a document

Postby Horizon » Fri Mar 29, 2019 6:34 pm

Natter wrote:Thanks. I usually just used a DOM


Hi Mr. Natter,

Can you please explain more DOM or give some sample?

Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Simulate a click on a document

Postby Natter » Fri Mar 29, 2019 8:51 pm

Hi, Mr. Horizon

Create Activex object and open website
oAx:Do("Navigate", myURL)

Any page of the website is a Document.
oDc:=oAx:GetProp("Document")

All we see on the page are the elements of the document (buttons, forms, etc.).
There was a map element on my page. I got this element method of a DOM
el:=oDc:getElementById("map")

Using other DOM methods, you can perform various manipulations on the element
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Simulate a click on a document

Postby Horizon » Sat Mar 30, 2019 7:50 am

Natter wrote:Hi, Mr. Horizon

Create Activex object and open website
oAx:Do("Navigate", myURL)

Any page of the website is a Document.
oDc:=oAx:GetProp("Document")

All we see on the page are the elements of the document (buttons, forms, etc.).
There was a map element on my page. I got this element method of a DOM
el:=oDc:getElementById("map")

Using other DOM methods, you can perform various manipulations on the element


Thank you.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Simulate a click on a document

Postby Horizon » Sat Mar 30, 2019 10:56 am

Hi,

https://vatandas.uyap.gov.tr/main/vatandas/giris.jsp

I want to click "E-Şifre Aracılığıyla Giriş" but, I can not find any name or id?

Can anyone help me?

Code: Select all  Expand view  RUN
PROCEDURE Web_Deneme()
Local IE, WshShell

    IE       := CreateObject("InternetExplorer.Application")
    WshShell := CreateObject("WScript.Shell")

    IE:Visible := .t.
    IE:Navigate( "https://vatandas.uyap.gov.tr/main/vatandas/giris.jsp" )

    Do While IE:Busy
       SysWait(1)
       SysRefresh() // To Refresh
       Loop
    Enddo
                                           
    Button  := ie:document:getElementsByClassName("a.btn.red-flamingo")
    TRY
       Button[0]:click()
       SysReFresh()
    CATCH
       Msginfo("Could not find DOM element 'button'")
//     IE:Quit()
       return(nil)
    END
       
RETURN 
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Simulate a click on a document

Postby Natter » Sat Mar 30, 2019 2:35 pm

The searched element may not have an identifier, name, type. In this case, there is a unique class -"btn red-flamingo"

getElementsByClassName()
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Simulate a click on a document

Postby Horizon » Sat Mar 30, 2019 4:26 pm

Natter wrote:The searched element may not have an identifier, name, type. In this case, there is a unique class -"btn red-flamingo"

getElementsByClassName()


Hi,

with this code there is no error but does not clicked() anymore.

Any advice?


Code: Select all  Expand view  RUN
    Button  := ie:document:getElementsByClassName("btn red-flamingo")
   
    TRY
       Button:click()
       SysReFresh()
    CATCH
       Msginfo("Could not find DOM element 'ilk giriş'")
//     IE:Quit()
       return(nil)
    END
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Simulate a click on a document

Postby Natter » Sat Mar 30, 2019 8:30 pm

Try so

oEvt:=button:createEventObject()
oEvt:type:="click"
button:fireEvent("onclick", oEvt)
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Simulate a click on a document

Postby Horizon » Sun Mar 31, 2019 9:51 am

Natter wrote:Try so

oEvt:=button:createEventObject()
oEvt:type:="click"
button:fireEvent("onclick", oEvt)


I think I can not find the Button object with
Code: Select all  Expand view  RUN
Button  := ie:document:getElementsByClassName("btn red-flamingo")


Code: Select all  Expand view  RUN
  Error description: (DOS Error -2147352570) WINOLE/1009  No exported method: CREATEEVENTOBJECT

Stack Calls
===========
   Called from:  => TOLEAUTO:CREATEEVENTOBJECT( 0 )
   Called from: .\ICRA_LBT.prg => WEB_DENEME( 722 )
 


after this I have remarked TRY, CATCH, END Statement. tried this.

Code: Select all  Expand view  RUN
Button  := ie:document:getElementsByClassName("btn red-flamingo")
       Button:click()


it also gives an error
Code: Select all  Expand view  RUN
  Error description: (DOS Error -2147352570) WINOLE/1009  No exported method: CLICK

Stack Calls
===========
   Called from:  => TOLEAUTO:CLICK( 0 )
   Called from: .\ICRA_LBT.prg => WEB_DENEME( 727 )


Is there any method to see HTMLDocument content to find out button?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Simulate a click on a document

Postby Giovany Vecchi » Sun Mar 31, 2019 12:24 pm

Hello try this way

Button := ie:document:All:Item("btn red-flamingo",0)
Button:Click(.t.)
User avatar
Giovany Vecchi
 
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests