I want to get the value of div using webdriver and not Selenium For example :
我想使用webdriver而不是Selenium来获取div的值例如:
<div class="headerbande">BIENVENUE</div>
Is there any method in webdriver to get "BIENVENUE" using class name ? Thanks in advance.
webdriver中是否有任何方法可以使用类名获取“BIENVENUE”?提前致谢。
5 个解决方案
#1
11
With java you would write:
使用java,你会写:
WebElement element = webdriver.findElement(By.className("headerbande"));
Take a look at Introducing the Selenium-WebDriver API by Example for examples in other languages.
有关其他语言的示例,请参阅示例中的Selenium-WebDriver API简介。
#2
3
Thanks Volkerk, I found the solution via your post
感谢Volkerk,我通过你的帖子找到了解决方案
WebElement webElement = driver.findElement(By.cssSelector("headerband"));
webElement.getText();
#3
2
in ruby, you can locate the element using
在ruby中,您可以使用找到元素
-
css selector
css选择器
web_element = driver.find_element(css: 'div.headerbande')
-
class
类
web_element = driver.find_element(class: 'headerbande')
-
id
ID
# if your element's id is 'headerbande' web_element = driver.find_element(id: 'headerbande')
#4
1
It is also possible to get value/text by using xpath as below:
也可以使用xpath获取值/文本,如下所示:
WebElement webElement = driver.findElement(By.xpath("//div[@class='headerbande']"));
webElement.getText();
OR, You can get text/value by using css Selector as below:
或者,您可以使用css Selector获取文本/值,如下所示:
WebElement webElement = driver.findElement(By.cssSelector("div.headerbande"));
webElement.getText();
#5
0
you can use: driver.findElementByClassName("headerbande").getText();
你可以使用:driver.findElementByClassName(“headerbande”)。getText();
#1
11
With java you would write:
使用java,你会写:
WebElement element = webdriver.findElement(By.className("headerbande"));
Take a look at Introducing the Selenium-WebDriver API by Example for examples in other languages.
有关其他语言的示例,请参阅示例中的Selenium-WebDriver API简介。
#2
3
Thanks Volkerk, I found the solution via your post
感谢Volkerk,我通过你的帖子找到了解决方案
WebElement webElement = driver.findElement(By.cssSelector("headerband"));
webElement.getText();
#3
2
in ruby, you can locate the element using
在ruby中,您可以使用找到元素
-
css selector
css选择器
web_element = driver.find_element(css: 'div.headerbande')
-
class
类
web_element = driver.find_element(class: 'headerbande')
-
id
ID
# if your element's id is 'headerbande' web_element = driver.find_element(id: 'headerbande')
#4
1
It is also possible to get value/text by using xpath as below:
也可以使用xpath获取值/文本,如下所示:
WebElement webElement = driver.findElement(By.xpath("//div[@class='headerbande']"));
webElement.getText();
OR, You can get text/value by using css Selector as below:
或者,您可以使用css Selector获取文本/值,如下所示:
WebElement webElement = driver.findElement(By.cssSelector("div.headerbande"));
webElement.getText();
#5
0
you can use: driver.findElementByClassName("headerbande").getText();
你可以使用:driver.findElementByClassName(“headerbande”)。getText();