private void GetNodeAtPoint(Point location) { PointInspection inspection = browser.MainFrame.Inspect(location); INode inspectionNode = inspection.UrlNode ?? inspection.Node; statusLabel1.Text = inspectionNode?.XPath ?? string.Empty; }
public static void Main() { using (IEngine engine = EngineFactory.Create()) { using (IBrowser browser = engine.CreateBrowser()) { browser.Size = new Size(700, 500); browser.Navigation.LoadUrl("https://www.teamdev.com").Wait(); PointInspection pointInspection = browser.MainFrame.Inspect(new Point(50, 50)); Console.WriteLine("Inspection result:"); Console.WriteLine($"\tAbsoluteImageUrl: {pointInspection.AbsoluteImageUrl}"); Console.WriteLine($"\tAbsoluteLinkUrl: {pointInspection.AbsoluteLinkUrl}"); if (pointInspection.LocalPoint != null) { Console.WriteLine($"\tLocalPoint: " + $"({pointInspection.LocalPoint.X}," + $"{pointInspection.LocalPoint.Y})"); } Console.WriteLine($"\tNode: {pointInspection.Node?.NodeName}"); Console.WriteLine($"\tUrlNode: {pointInspection.UrlNode?.NodeName}"); } } Console.WriteLine("Press any key to terminate..."); Console.ReadKey(); }
private void GetNodeAtPoint(Point location) { double scale = PresentationSource.FromVisual(this)?.CompositionTarget?.TransformToDevice.M11 ?? 1; location = new Point((int)Math.Round(location.X * scale), (int)Math.Round(location.Y * scale)); PointInspection inspection = browser.MainFrame.Inspect(location); INode inspectionNode = inspection.UrlNode ?? inspection.Node; statusLabel1.Content = inspectionNode?.XPath ?? string.Empty; }