BIENVENUE...">

Get DIV Value - WebDriver (Selenium)

I want to get the div value using webdriver and not Selenium For example:

<div class="headerbande">BIENVENUE</div> 

Is there any method in webdriver to get "BIENVENUE" using the class name? Thanks in advance.

+6
source share
5 answers

Using java you should write:

 WebElement element = webdriver.findElement(By.className("headerbande")); 

Take a look at Introducing the Selenium-WebDriver Example API for examples in other languages.

+11
source

Thanks Volkerk, I found a solution through your message

 WebElement webElement = driver.findElement(By.cssSelector("headerband")); webElement.getText(); 
+3
source

in ruby, you can find the element using

  • css selector

     web_element = driver.find_element(css: 'div.headerbande') 
  • the class

     web_element = driver.find_element(class: 'headerbande') 
  • ID

     # if your element id is 'headerbande' web_element = driver.find_element(id: 'headerbande') 
+2
source

You can also get the value / text using xpath, as shown below:

 WebElement webElement = driver.findElement(By.xpath("//div[@class='headerbande']")); webElement.getText(); 

OR, you can get the text / value using css Selector, as shown below:

 WebElement webElement = driver.findElement(By.cssSelector("div.headerbande")); webElement.getText(); 
+1
source

you can use: driver.findElementByClassName ("headerbande") GetText () ;.

0
source

Source: https://habr.com/ru/post/918725/


All Articles