Found 86 Articles for DOM

How to convert a DOM Nodelist to an Array using JavaScript?

Jaisshree
Updated on 09-Aug-2023 16:45:07

387 Views

To write javascript advanced code you can run across instances where you need to convert a DOM (Document Object Model) NodeList to a more adaptable data structure like an array. Although nodelist is just like an array in any programming language. However, it does not contain fever characteristics than an array. You can use Javascript to convert a nodelist into an array to work more appropriately. Example 1 This example provides code to convert a nodelist into an array using javascript. The code uses the nodeListToArray function to perform the conversion. Algorithm Step 1 :Create an array ... Read More

Difference between SAX Parser and DOM Parser in Java

Shriansh Kumar
Updated on 20-Jul-2023 19:45:54

2K+ Views

Both SAX and DOM are a type of XML parser APIs. Here, API stands for Application Programming Interface and Parser is used to read and extract content from an XML document in desired format. From this line, it is clear that SAX and DOM are used to read XML documents. APIs are a modern way to migrate real time information on the Web. In this article, we will discuss the difference between SAX and DOM Parser in Java. Type of XML Parser Before going further in this article, let’s briefly discuss XML and its type. XML Its full form is ... Read More

What does fluent wait perform?

Debomita Bhattacharjee
Updated on 10-Jun-2020 14:38:47

423 Views

Fluent wait is a dynamic wait which makes the driver pause for a condition which is checked at a frequency before throwing an exception. The element is searched in DOM not constantly but at a regular interval of time.For example, if the wait is for 5 seconds, FluentWait monitors the DOM at regular intervals (defined by polling during time). In FluentWait, customized wait methods based on conditions need to be built.Syntax −Wait w = new FluentWait< WebDriver >(driver) .withTimeout (10, SECONDS) .pollingEvery (2, SECONDS) .ignoring (NoSuchElementException.class)Exampleimport 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; import org.openqa.selenium.support.ui.Wait; import ... Read More

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

Debomita Bhattacharjee
Updated on 10-Jun-2020 13:19:00

856 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 identify the nth sub element using xpath?

Debomita Bhattacharjee
Updated on 10-Jun-2020 13:06:19

5K+ 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.Exampleimport 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 SubElement {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.tutorialspoint.com/index.htm";       driver.get(url);       driver.manage().window().maximize();       driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);       // xpath using position() targeting the first element with type text       driver.findElement(By.xpath("//input[@type='text'][position()=1]"))     ... Read More

Parse HTML with PHP's HTML DOMDocument

AmitDiwan
Updated on 07-Apr-2020 11:36:35

410 Views

The text inside a tag inside class="text" inside with class="main" can be obtained with the following code −Example$html = nodeValue)); }OutputThis will produce the following output −string ‘This is text 1’ (length=14) string ‘This is text 2' (length=14)

How to check if element exists in the visible DOM?

Ayush Gupta
Updated on 27-Nov-2019 10:42:43

621 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.

HTML DOM Style borderRight Property

AmitDiwan
Updated on 22-Oct-2019 14:08:35

69 Views

The HTML DOM borderRight property is used as a shorthand for getting or setting the Right border properties for an element. The borderRight property contains border-Right-width, border-Right-style, border-Right-color.Following is the syntax for −Setting the borderRight property:object.style.borderRight = "width style color|initial|inherit"The above properties are explained as follows −ParameterDescriptionwidthFor setting the Right border width.styleFor setting the Right border style.colorFor setting the Right border color.initialFor setting this property to default value.inheritTo inherit the parent property value.Let us look at an example for the borderRight property −Example Live Demo    #P1 {       border-Right: 4px solid magenta;       ... Read More

HTML DOM Style borderRadius Property

AmitDiwan
Updated on 22-Oct-2019 14:03:23

185 Views

The HTML DOM borderRadius propert is used to add rounded corners to the element’s four sides. Using this property, we can set and get the border radius properties like borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius.Following is the syntax for −Setting the borderRadius property:object.style.borderRadius = "1-4 length|% / 1-4 length|%|initial|inherit"The property values are explained as follows −ValueDescriptionlengthFor defining the borders shape.%For defining the borders shape in percentage.initialFor setting this property to initial value.inheritTo inherit the parent property valueLet us look at an example for the borderRadius property −Example Live Demo    #DIV1{       height: 100px;       width: ... Read More

HTML DOM Style borderLeftWidth Property

AmitDiwan
Updated on 22-Oct-2019 13:59:02

61 Views

The HTML DOM borderLeftWidth property is used for setting or getting the Left border width for an element.Following is the syntax for −Setting the borderLeftWidth property −object.style.borderLeftWidth = "thin|medium|thick|length|initial|inherit"The property values are explained as follows −ValueDescriptionthinThis specifies a thin border.mediumThis specifies the medium border and is the default value.thickThis specifies a thin border.lengthFor setting this property to default value.initialFor setting this property to initial value.inheritTo inherit the parent property valueLet us look at an example for the borderLeftWidth Property −Example Live Demo    #DIV1{       height: 100px;       width: 200px;       border: ... Read More

1 2 3 4 5 ... 9 Next
Advertisements