Tuesday, May 7, 2013

GeckoFx getElementByID() click() method missing

In an application that i am creating using Gecko FX version 15, I noticed that getElementsByTagName() has an invoke member click() as shown below:
Code:
this.Document.GetElementsByTagName(geckoElement.TagName)[indexSearchElement].Click();
But missing in getElementByID(). After experimenting for a few hours, I came up with the solution below:
Code:
((GeckoHtmlElement)this.Document.GetElementById(elemId)).Click();  
The trick was to cast it as GeckoHtmlElement.
Greg

6 comments:

  1. tnx.
    solved my problem

    ReplyDelete
  2. Thanx! it helped me too!

    ReplyDelete
  3. For Each curElement As GeckoElement In theElementCollection
    If curElement.GetAttribute("name").Equals("signIn") Then
    curElement.InvokeMember("click") <= this doesn't not work
    End If
    Next

    help me,,,,,

    ReplyDelete
    Replies
    1. Hi,

      When using GetElementById() make sure that you are referencing the ID itself and not looping through the controlls collection. :)

      Delete