Monday 15 July 2013

java - Get text of css element selenium -


I am trying to use Selenium to access the text of a CSS element. WebElement test = driver.findElement (by.cssSelector ("div.CLFSBTextWithLink")); Println (test.getText ());

This is what I am doing now but the output is empty. For example, a website called "company" can be a link or text, and when I say element to use selenium, it says that the target CSS = div.CLFSBTextWithLink is. Now I want to be able to get the value "company"

If you go, "Bob was a man named Bob" and hit Submit, then you will see the Bob Bob name under the unit person. I'm basically trying to get that name "Bob Bob".


From the docs:

get the view css) The inner text of this element

but the text Initially hidden, you have to expand the first person element to make it visible. In this particular "Bob Bob" case, you can use it:

  driver.findElement (By.id ("toggleVisibilityImage1")). Click ();   

But always make sure you are clicking the right extension. To make it more common, it selects the expander next to the "person" category:

  // input [@ class = 'collapseExpandIcon' and (../text () = 'Person')]   

More explanation:

  SELECT ANT < Input & gt; ELEMENT // Input [] This is an Expander @ class = 'Drop Expand Icon' and its parent has the text "person" and (../text()='Person ')   < / Div> 

No comments:

Post a Comment