【发布时间】:2013-11-09 05:42:42
【问题描述】:
在下面的代码中,我需要在Hex format 中打印color。
第一个打印语句以RGB 格式显示值,即rgb(102,102,102)。
Second 语句在 Hex 中显示值,即 #666666
但我手动将值输入到第二个打印语句 102,102,102。
有什么方法可以将我从第一个语句(颜色)得到的值传递到第二个打印语句并得到结果?
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Google {
public static void main(String[] args) throws Exception {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
String Color = driver.findElement(By.xpath("//div[@class='gb_e gb_f gb_g gb_xb']/a")).getCssValue("color");
System.out.println(Color);
String hex = String.format("#%02x%02x%02x", 102,102,102);
System.out.println(hex);
}
}
【问题讨论】:
标签: java selenium selenium-webdriver