Found 86 Articles for DOM

What does fluent wait perform?

Debomita Bhattacharjee
Updated on 10-Jun-2020 14:38:47
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
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
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
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
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
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
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
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

HTML DOM Style borderLeftStyle Property

AmitDiwan
Updated on 22-Oct-2019 13:55:48
The borderLeftStyle property is used for setting or returning the left border style for an element.Following is the syntax for −Setting the borderLeftStyle property −object.style.borderLeftStyle = valueThe above properties are explained as follows −ValueDescriptionNoneThis is the default value specifying no border.HiddenThis is same as "none" but will still take border space. It is basically transparent but still there.dottedThis defines a dotted border.dashedThis defines a dashed border.solidThis defines a solid border.doubleThis defines a double bordergrooveThis defines a 3d groove border and is the opposite of ridgeridgeThis defines a 3D ridged border and is the opposite of grooveinsetThis defines a 3D inset ... Read More

HTML DOM Style borderLeftColor Property

AmitDiwan
Updated on 22-Oct-2019 13:36:19
The HTML DOM borderLeftColor property is used to get or set the color for left border of an element.Following is the syntax for −Setting the borderImageWidth property −object.style.borderLeftColor = "color|transparent|initial|inherit"The above properties are explained as follows −ValueDescriptioncolorFor specifying the left border color. The default color is set to blacktransparentThe makes the left border color transparent and the underlying content can be seen.initialFor setting this property to default value.inheritTo inherit the parent property value.Let us look at an example for the borderLeftColor property −Example Live Demo    #IMG1{       border-left:solid 8px;       border-left-color: orange;   ... Read More
1 2 3 4 5 ... 9 Next
Advertisements