Information about web elements

What you can learn about an element.

There are a number of details you can query about a specific element.

Is Displayed

This method is used to check if the connected Element is displayed on a webpage. Returns a Boolean value, True if the connected element is displayed in the current browsing context else returns false.

This functionality is mentioned in, but not defined by the w3c specification due to the impossibility of covering all potential conditions. As such, Selenium cannot expect drivers to implement this functionality directly, and now relies on executing a large JavaScript function directly. This function makes many approximations about an element’s nature and relationship in the tree to return a value.

         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    displayed_value = driver.find_element(name: 'email_input').displayed?
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
//navigates to url
 driver.get("https://www.selenium.dev/selenium/web/inputs.html")

 //returns true if element is displayed else returns false
 val flag = driver.findElement(By.name("email_input")).isDisplayed()

Is Enabled

This method is used to check if the connected Element is enabled or disabled on a webpage. Returns a boolean value, True if the connected element is enabled in the current browsing context else returns false.

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    enabled_value = driver.find_element(name: 'email_input').enabled?
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
//navigates to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

//returns true if element is enabled else returns false
val attr = driver.findElement(By.name("button_input")).isEnabled()

Elemento está selecionado

Este método determina se o elemento referenciado é Selected ou não. Este método é amplamente utilizado em caixas de seleção, botões de opção, elementos de entrada e elementos de opção.

Retorna um valor booleano, true se o elemento referenciado for selected no contexto de navegação atual, caso contrário, retorna false.

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    selected_value = driver.find_element(name: 'email_input').selected?
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
 //navigates to url
 driver.get("https://www.selenium.dev/selenium/web/inputs.html")

 //returns true if element is checked else returns false
 val attr =  driver.findElement(By.name("checkbox_input")).isSelected()

Coletar TagName do elemento

É usado para buscar o TagName do elemento referenciado que tem o foco no contexto de navegação atual.

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    tag_name = driver.find_element(name: 'email_input').tag_name
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
//navigates to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

//returns TagName of the element
val attr =  driver.findElement(By.name("email_input")).getTagName()

Coletar retângulo do elemento

É usado para buscar as dimensões e coordenadas do elemento referenciado.

O corpo de dados buscado contém os seguintes detalhes:

  • Posição do eixo X a partir do canto superior esquerdo do elemento
  • posição do eixo y a partir do canto superior esquerdo do elemento
  • Altura do elemento
  • Largura do elemento
        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    rect = driver.find_element(By.NAME, "range_input").rect
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    size = driver.find_element(name: 'email_input').size
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    let object = await driver.findElement(By.name('range_input')).getRect();
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
// Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

// Returns height, width, x and y coordinates referenced element
val res = driver.findElement(By.name("range_input")).rect

// Rectangle class provides getX,getY, getWidth, getHeight methods
println(res.getX())

Coletar valor CSS do elemento

Recupera o valor da propriedade de estilo computado especificada de um elemento no contexto de navegação atual.

     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
// Navigate to Url
driver.get("https://www.selenium.dev/selenium/web/colorPage.html")

// Retrieves the computed style property 'color' of linktext
val cssValue = driver.findElement(By.id("namedColor")).getCssValue("background-color")

Coletar texto do elemento

Recupera o texto renderizado do elemento especificado.

       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    text = driver.find_element(By.TAG_NAME, "h1").text
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    text = driver.find_element(xpath: '//h1').text
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
// Navigate to URL
driver.get("https://www.selenium.dev/selenium/web/linked_image.html")

// retrieves the text of the element
val text = driver.findElement(By.id("justanotherlink")).getText()

Fetching Attributes or Properties

Fetches the run time value associated with a DOM attribute. It returns the data associated with the DOM attribute or property of the element.

      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
Show full example
package dev.selenium.elements;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InformationTest {

    @Test
    public void informationWithElements() {
    	
    	 WebDriver driver = new ChromeDriver();
         driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
         // Navigate to Url
         driver.get("https://www.selenium.dev/selenium/web/inputs.html");

    	  // isDisplayed        
        // Get boolean value for is element display
        boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
        assertEquals(isEmailVisible,true);

        // isEnabled
        // returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);

        // isSelected
        // returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 

        // TagName
        // returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 

        // GetRect
        // Returns height, width, x and y coordinates referenced element
        Rectangle res =  driver.findElement(By.name("range_input")).getRect();
        // Rectangle class provides getX,getY, getWidth, getHeight methods
        assertEquals(res.getX(),10);
        
     
     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
        
        
       // GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
        
        
      // FetchAttributes
      // identify the email text box
      WebElement emailTxt = driver.findElement(By.name(("email_input")));
      // fetch the value property associated with the textbox
      String valueInfo = emailTxt.getAttribute("value");
      assertEquals(valueInfo,"admin@localhost");
        
        
        driver.quit();
    }

}
    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
Show full example
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
    # Initialize WebDriver
    driver = webdriver.Chrome()
    driver.implicitly_wait(0.5)

    driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # isDisplayed
    is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
    assert is_email_visible == True

    # isEnabled
    is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
    assert is_enabled_button == True

    # isSelected
    is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
    assert is_selected_check == True

    # TagName
    tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
    assert tag_name_inp == "input"

    # GetRect
    rect = driver.find_element(By.NAME, "range_input").rect
    assert rect["x"] == 10

    # CSS Value
    css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
        "font-size"
    )
    assert css_value == "13.3333px"

    # GetText
    text = driver.find_element(By.TAG_NAME, "h1").text
    assert text == "Testing Inputs"

    # FetchAttributes
    email_txt = driver.find_element(By.NAME, "email_input")
    value_info = email_txt.get_attribute("value")
    assert value_info == "admin@localhost"
            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
Show full example
using System;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;


namespace SeleniumDocs.Elements
{
    [TestClass]
    public class InformationTest 
    {
        [TestMethod]
        public void TestInformationCommands(){
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);

            // Navigate to Url
            driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
            // isDisplayed        
            // Get boolean value for is element display
            bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
            Assert.AreEqual(isEmailVisible, true);

            // isEnabled
            // returns true if element is enabled else returns false
            bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
            Assert.AreEqual(isEnabledButton, true);

            // isSelected
            // returns true if element is checked else returns false
            bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
            Assert.AreEqual(isSelectedCheck, true);

            // TagName
            // returns TagName of the element
            string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
            Assert.AreEqual(tagNameInp, "input");

            // Get Location and Size
            // Get Location
            IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
            Point point = rangeElement.Location;
            Assert.IsNotNull(point.X);
            // Get Size
            int height=rangeElement.Size.Height;
            Assert.IsNotNull(height);

            // Retrieves the computed style property 'font-size' of field
            string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
            Assert.AreEqual(cssValue, "13.3333px");

            // GetText
            // Retrieves the text of the element
            string text = driver.FindElement(By.TagName("h1")).Text;
            Assert.AreEqual(text, "Testing Inputs");

            // FetchAttributes
            // identify the email text box
            IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
            // fetch the value property associated with the textbox
            string valueInfo = emailTxt.GetAttribute("value");
            Assert.AreEqual(valueInfo, "admin@localhost");
            
            //Quit the driver
            driver.Quit();
        }
    }
}
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Element Information' do
  let(:driver) { start_session }
  let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }

  before { driver.get(url) }

  it 'checks if an element is displayed' do
    displayed_value = driver.find_element(name: 'email_input').displayed?
    expect(displayed_value).to be_truthy
  end

  it 'checks if an element is enabled' do
    enabled_value = driver.find_element(name: 'email_input').enabled?
    expect(enabled_value).to be_truthy
  end

  it 'checks if an element is selected' do
    selected_value = driver.find_element(name: 'email_input').selected?
    expect(selected_value).to be_falsey
  end

  it 'gets the tag name of an element' do
    tag_name = driver.find_element(name: 'email_input').tag_name
    expect(tag_name).not_to be_empty
  end

  it 'gets the size and position of an element' do
    size = driver.find_element(name: 'email_input').size
    expect(size.width).to be_positive
    expect(size.height).to be_positive
  end

  it 'gets the css value of an element' do
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
    expect(css_value).not_to be_empty
  end

  it 'gets the text of an element' do
    text = driver.find_element(xpath: '//h1').text
    expect(text).to eq('Testing Inputs')
  end

  it 'gets the attribute value of an element' do
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
    expect(attribute_value).not_to be_empty
  end
end
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
Show full example
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  beforeEach(async ()=> {
    await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
  })
  
  it('Check if element is displayed', async function () {
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
    
    assert.equal(result,true);
  });
  
  it('Check if button is enabled', async function () {
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
  
    assert.equal(element, true);
  });
  
  it('Check if checkbox is selected', async function () {
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
  
    assert.equal(isSelected, true);
  });
  
  it('Should return the tagname', async function () {
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
  
    assert.equal(value, "input");
  });
  
  it('Should be able to fetch element size and position ', async function () {
    // Returns height, width, x and y position of the element
    let object = await driver.findElement(By.name('range_input')).getRect();
    
    assert.ok(object.height!==null)
    assert.ok(object.width!==null)
    assert.ok(object.y!==null)
    assert.ok(object.x!==null)
    
  });
  
  it('Should be able to fetch attributes and properties ', async function () {
    // identify the email text box
    const emailElement = await driver.findElement(By.xpath('//input[@name="email_input"]'));
    
    //fetch the attribute "name" associated with the textbox
    const nameAttribute = await emailElement.getAttribute("name");
  
    assert.equal(nameAttribute, "email_input")
  });
  
  after(async () => await driver.quit());
});


describe('Element Information Test', function () {
  let driver;
  
  before(async function () {
    driver = await new Builder().forBrowser('chrome').build();
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/colorPage.html');
    // Returns background color of the element
    let value = await driver.findElement(By.id('namedColor')).getCssValue('background-color');
    
    assert.equal(value, "rgba(0, 128, 0, 1)");
  });
  
  it('Should return the css specified CSS value', async function () {
    await driver.get('https://www.selenium.dev/selenium/web/linked_image.html');
    // Returns text of the element
    let text = await driver.findElement(By.id('justanotherLink')).getText();
    
    assert.equal(text, "Just another link.");
  });
  
  after(async () => await driver.quit());
});
// Navigate to URL
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

//fetch the value property associated with the textbox
val attr = driver.findElement(By.name("email_input")).getAttribute("value")