Anandh R
Anandh R

Reputation: 109

Any possible to print multiple values in single cell using selenium web driver

For example:

for(int i=1;i<=2;i++){
WebElement points = driver.findElement(By.id("id["+i+"]"));
points.getCssValues("margin-bottom");
}

In the above example, margin get have two values. how to print these values in single cell.

Upvotes: 0

Views: 593

Answers (1)

Saurabh Gaur
Saurabh Gaur

Reputation: 23825

In this code, get margin bottom for two web elements. These two web element's margin have to print in single cell

You're question is not much clear, but I think you want to get css values from multiple element into single variable and then want to use somewhere.

You need concatenate elements margin css values then print where you want as below :-

String margin= "";
for(int i=1;i<=2;i++)
{ 
  WebElement points = driver.findElement(By.id("id["+i+"]")); 
  margin += points.getCssValues("margin-bottom"); 
} 
System.out.println(margin); // this would print both margin into single

Upvotes: 1

Related Questions