Web要素に関する情報

要素について学ぶことができること。

特定の要素についてクエリできる詳細情報がいくつかあります。

表示されているかどうか

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();
        assertEquals(isEmailVisible,true);
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Get boolean value for is element display
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">// Navigate to Url</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Url</span><span style="color:#000;font-weight:bold">=</span> <span style="color:#4e9a06">&#34;https://www.selenium.dev/selenium/web/inputs.html&#34;</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">// isDisplayed        </span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">// Get boolean value for is element display</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">bool</span> <span style="color:#000">isEmailVisible</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;email_input&#34;</span><span style="color:#000;font-weight:bold">)).</span><span style="color:#000">Displayed</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">isEmailVisible</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">true</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    displayed_value = driver.find_element(name: 'email_input').displayed?
    // Resolves Promise and returns boolean value
    let result =  await driver.findElement(By.name("email_input")).isDisplayed();
//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()

要素が有効か

このメソッドは、接続された要素がWebページで有効または無効になっているかどうかを確認するために使います。 ブール値を返し、現在のブラウジングコンテキストで接続されている要素が 有効(enabled) になっている場合は True 、そうでない場合は false を返します。

        //isEnabled
       //returns true if element is enabled else returns false
        boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
        assertEquals(isEnabledButton,true);
    # Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # Returns true if element is enabled else returns false
value = driver.find_element(By.NAME, 'button_input').is_enabled()
  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//isEnabled</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//returns true if element is enabled else returns false</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">bool</span> <span style="color:#000">isEnabledButton</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;button_input&#34;</span><span style="color:#000;font-weight:bold">)).</span><span style="color:#000">Enabled</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">isEnabledButton</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">true</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    enabled_value = driver.find_element(name: 'email_input').enabled?
    // Resolves Promise and returns boolean value
    let element =  await driver.findElement(By.name("button_input")).isEnabled();
 //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()
  

要素が選択されているかどうか

このメソッドは、参照された要素が選択されているかどうかを判断します。 このメソッドは、チェックボックス、ラジオボタン、入力要素、およびオプション要素で広く使われています。

ブール値を返し、現在のブラウジングコンテキストで参照された要素が 選択されている 場合は True 、そうでない場合は false を返します。

        //isSelected
        //returns true if element is checked else returns false
        boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
        assertEquals(isSelectedCheck,true); 
    # Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # Returns true if element is checked else returns false
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//isSelected</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//returns true if element is checked else returns false</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">bool</span> <span style="color:#000">isSelectedCheck</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;checkbox_input&#34;</span><span style="color:#000;font-weight:bold">)).</span><span style="color:#000">Selected</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">isSelectedCheck</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">true</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    selected_value = driver.find_element(name: 'email_input').selected?
    // Returns true if element ins checked else returns false
    let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();
 //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()
  

要素のタグ名を取得

これは、現在のブラウジングコンテキストにフォーカスがある参照された要素の TagName を取得するために使います。

        //TagName
        //returns TagName of the element
        String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
        assertEquals(tagNameInp,"input"); 
    # Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # Returns TagName of the element
attr = driver.find_element(By.NAME, "email_input").tag_name
  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//TagName</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//returns TagName of the element</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">string</span> <span style="color:#000">tagNameInp</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;email_input&#34;</span><span style="color:#000;font-weight:bold">)).</span><span style="color:#000">TagName</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">tagNameInp</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#4e9a06">&#34;input&#34;</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    tag_name = driver.find_element(name: 'email_input').tag_name
    // Returns TagName of the element
    let value = await driver.findElement(By.name('email_input')).getTagName();
 //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()
  

要素矩形を取得

参照される要素の寸法と座標を取得するために使います。

取得データのbodyには、次の詳細が含まれます。

  • 要素の左上隅からのx軸の位置
  • 要素の左上隅からのy軸の位置
  • 要素の高さ
  • 要素の幅
        //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);
    # Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

    # Returns height, width, x and y coordinates referenced element
res = driver.find_element(By.NAME, "range_input").rect
  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//Get Location and Size</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//Get Location</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">IWebElement</span> <span style="color:#000">rangeElement</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;range_input&#34;</span><span style="color:#000;font-weight:bold">));</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Point</span> <span style="color:#000">point</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">rangeElement</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Location</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">IsNotNull</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">point</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">X</span><span style="color:#000;font-weight:bold">);</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//Get Size</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">int</span> <span style="color:#000">height</span><span style="color:#000;font-weight:bold">=</span><span style="color:#000">rangeElement</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Size</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Height</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">IsNotNull</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">height</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    size = driver.find_element(name: 'email_input').size
// 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())
  

要素のCSSの値を取得

現在のブラウジングコンテキスト内の要素の指定された計算したスタイル属性の値を取得します。

     // Retrieves the computed style property 'font-size' of field
     String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
     assertEquals(cssValue, "13.3333px");
    # Navigate to Url
driver.get('https://www.selenium.dev/selenium/web/colorPage.html')

    # Retrieves the computed style property 'color' of linktext
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')

  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">// Retrieves the computed style property &#39;font-size&#39; of field</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">string</span> <span style="color:#000">cssValue</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;color_input&#34;</span><span style="color:#000;font-weight:bold">)).</span><span style="color:#000">GetCssValue</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;font-size&#34;</span><span style="color:#000;font-weight:bold">);</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">cssValue</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#4e9a06">&#34;13.3333px&#34;</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    css_value = driver.find_element(name: 'email_input').css_value('background-color')
// 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")

  

要素テキストを取得

指定された要素のレンダリングされたテキストを取得します。

        //GetText
       // Retrieves the text of the element
        String text = driver.findElement(By.tagName("h1")).getText();
        assertEquals(text, "Testing Inputs");
    # Navigate to url
driver.get("https://www.selenium.dev/selenium/web/linked_image.html")

    # Retrieves the text of the element
text = driver.find_element(By.ID, "justanotherlink").text
  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//GetText</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">// Retrieves the text of the element</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">string</span> <span style="color:#000">text</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">TagName</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;h1&#34;</span><span style="color:#000;font-weight:bold">)).</span><span style="color:#000">Text</span><span style="color:#000;font-weight:bold">;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">text</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#4e9a06">&#34;Testing Inputs&#34;</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    text = driver.find_element(xpath: '//h1').text
// 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");
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Identify the email text box
email_txt = driver.find_element(By.NAME, "email_input")

# Fetch the value property associated with the textbox
value_info = email_txt.get_attribute("value")
  
  




  




  













  
  
  

  
  
  

  
  
    
    
    
    
    
    
  

  <div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cs" data-lang="cs"><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//FetchAttributes</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//identify the email text box</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">IWebElement</span> <span style="color:#000">emailTxt</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">driver</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">FindElement</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">By</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">Name</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;email_input&#34;</span><span style="color:#000;font-weight:bold">));</span>
</span></span><span style="display:flex;"><span>            <span style="color:#8f5902;font-style:italic">//fetch the value property associated with the textbox</span>
</span></span><span style="display:flex;"><span>            <span style="color:#204a87;font-weight:bold">string</span> <span style="color:#000">valueInfo</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#000">emailTxt</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">GetAttribute</span><span style="color:#000;font-weight:bold">(</span><span style="color:#4e9a06">&#34;value&#34;</span><span style="color:#000;font-weight:bold">);</span>
</span></span><span style="display:flex;"><span>            <span style="color:#000">Assert</span><span style="color:#000;font-weight:bold">.</span><span style="color:#000">AreEqual</span><span style="color:#000;font-weight:bold">(</span><span style="color:#000">valueInfo</span><span style="color:#000;font-weight:bold">,</span> <span style="color:#4e9a06">&#34;admin@localhost&#34;</span><span style="color:#000;font-weight:bold">);</span></span></span></code></pre></div>

  <div class="text-end pb-2">
    <a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" target="_blank">
      <i class="fas fa-external-link-alt pl-2"></i>
        <strong>View full example on GitHub</strong>
    </a>
  </div>
    attribute_value = driver.find_element(name: 'number_input').attribute('value')
// 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")