Element Info & Attributes

Is Visible In Viewport

Determines whether the element is completely within the visible browser viewport by comparing its bounding rectangle to the windows width and height, and returns a boolean result.

Examples

GPAL Fluent: High-level fluent C# API

//Asks whether the whole element is inside the viewport, not merely rendered. Displayed on the element answers the second question and is the one to reach for when position does not matter.

bool visible = ElementHelper.IsVisibleInViewport(browser, gPalElement);

MagicHelper: MagicHelper utility library

browser.MagicHelper.IsVisibleInViewport(string css);

browser.MagicHelper.IsVisibleInViewport(string xpath);

Puppeteer Client: Puppeteer-style C# client

//PuppeteerClient.IsVisibleInViewport takes a resolved backendNodeId (or GPALElement), not a raw CSS/XPath selector.

browser.PuppeteerClient.IsVisibleInViewport(string backendNodeId).Execute();

Puppeteer Communicator: Low-level communicator

await browser.PuppeteerCommunicator.IsVisibleInViewport(dynamic elemsOrBackendNodeId, string sessionId);

REST Client: Direct REST/HTTP client

browser.OttoMagicClient.WithEndpoint(ApiEndpoint.IsVisibleInViewport).WithCss(string css).Execute();

browser.OttoMagicClient.WithEndpoint(ApiEndpoint.IsVisibleInViewport).WithXPath(string xpath).Execute();

💬 Ask GPAL