0

I'm currently doing a windows application in c# whereby each time I click on the webpage, it will create an alertbox stating the id/ class that particular item is in. The situation is same as using the Page ruler extension for Google Chrome. Instead this application is in order to read from Internet Explorer browser. A few different method that i have used is Selenium but it directly hard code the id/class into the c# function which is not what i needed. Anyone have any suggestion on how to proceed with this steps?

I'm currently actually trying to duplicate the Page ruler extension (Google Chrome extension) for my application so that it can be used in Internet Explorer browser. The situation that caused i'm unable to use Selenium is: - It directly hardcoded each of the the id/class into the function before action. What I needed is something like returning the whole id/class in the webpage. I used CssSelector but it just return id=123445568

The next solution is using HTMLAgilityPack which i'm facing the same problem as Selemium. Before any of you closed this, please clarify any further information that you needed in order for me to add more details on my requirements

Ng Yang Yang
  • 35
  • 1
  • 6

1 Answers1

1

I'm not sure what do you mean by Internet Explorer web page? Because web page is accessible from a URL and you can open it in any browser you like.

If you're using WebBrowser class in your code, and you want to get element ID, you can do something like this.

But, If you're looking for complete control on your DOM, you can instead use Html Agility Pack. It's an Html parser that helps you to read or write DOM easily.

UPDATE based on question update

IMHO it's better to use JS Or JQuery to recreate that extension, but if you persist on using C#, take a look at this great SO answer about how to get started with IE Add-Ons.

itsMasoud
  • 1,335
  • 2
  • 9
  • 25
  • For the example of retrieving the element id from image, how would it applicable on a webpage since a webpage has many id/class. When i meant by Internet Explorer webpage, I meant that i need to read the current IE webpage that was currently open in my IE browser and not read from a hardcoded url which i usually saw from example that was given online. If you check Page ruler redux extension from Google Chrome, it exactly seperate each section in the webpage and display its id/class – Ng Yang Yang Nov 01 '19 at 03:34