DOM Articles

Page 4 of 4

DOMException Failed to load because no supported source was found

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 3K+ Views

The "DOMException Failed to load because no supported source was found" error occurs when media elements (video, audio) cannot load their source files. This is commonly caused by CORS restrictions, incorrect file paths, or unsupported formats. Common Causes This error typically happens due to: Cross-Origin Resource Sharing (CORS) restrictions Incorrect file paths or missing media files Unsupported media formats Server configuration issues Method 1: Setting crossOrigin for CORS When loading media from different domains, set the crossOrigin attribute to handle CORS restrictions: const ...

Read More

How to identify the nth sub element using xpath?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 7K+ Views

We can identify the nth sub element using xpath in the following ways: By adding square brackets with index. By using position() method in xpath. Method 1: Using Square Brackets with Index The most common approach is to add square brackets with the desired index number after the element selector: // Select the 2nd div element //div[2] // Select the 3rd li element inside ul //ul/li[3] // Select the first input with type='text' //input[@type='text'][1] Method 2: Using position() Function The position() function provides another way to target elements ...

Read More

What does fluent wait perform?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 608 Views

Fluent wait is a dynamic wait mechanism in Selenium that allows the WebDriver to pause and repeatedly check for a condition at regular intervals before throwing an exception. Unlike implicit wait, FluentWait provides more control over polling frequency and exception handling. How FluentWait Works FluentWait monitors the DOM at regular intervals (defined by polling frequency) rather than constantly checking. For example, if you set a 30-second timeout with 3-second polling, the driver will check the condition every 3 seconds for up to 30 seconds before timing out. Syntax Wait wait = new FluentWait(driver) ...

Read More

Parse HTML with PHP's HTML DOMDocument

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 575 Views

PHP's DOMDocument class provides powerful tools for parsing and manipulating HTML content. You can extract specific elements using XPath queries or DOM traversal methods. Example The following example shows how to extract text from nested elements using XPath −

Read More

What are the differences between findElement() and findElements() methods?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 10-Jun-2020 1K+ Views

findElement() and findElements() method tries to search an element in DOM.The differences between them are listed below −sl.no.findElement()findElements()1It returns the first web element which matches with the locator.It returns all the web elements which match with the locator.2Syntax − WebElement button = webdriver.findElement(By.name(""));Syntax − List buttons = webdriver.findElements(By.name(""));3NoSuchElementException is thrown if there are no matching web elementsEmpty list is returned if there are no matching elements.ExampleUsing findElements ().import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class RowFindElements {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver ...

Read More

How to check if element exists in the visible DOM?

Ayush Gupta
Ayush Gupta
Updated on 27-Nov-2019 808 Views

We can use the Node.contains method to do this check. The Node.contains() method returns a Boolean value indicating whether a node is a descendant of a given node, i.e. the node itself, one of its direct children (childNodes), one of the children's direct children, and so on.ExampleFor example, you are looking for an element with id test, you can use the following −const elem = document.querySelector('#test'); console.log(document.body.contains(elem));This will log true or false based on whether the element is present in the visible DOM.

Read More
Showing 31–36 of 36 articles
« Prev 1 2 3 4 Next »
Advertisements