Skip to content
Advertisement

I would like to fetch text with color from web table and print in excel using selenium web driver and apache poi

I get color of the text and stored in ‘textColor’. Now i need to pass this color to font.setColor. I mean instead of hard code color, i need to pass the textColor to font.setColor which mean i need to place it instead of Light_ORANGE. Could anyone help me to fix this. At the end i need to extract the text with color and the same text with color need to be write in excel.

WebElement winner = driver.findElement(By.xpath(“//div[@url=’/api/html/cricket-scorecard/23253′]/div[1]”));

JavaScript

Advertisement

Answer

String textColor = winner.getCssValue("color"); returns a String, such as rgba(0, 0, 0, 1).

You can modify your code refer to this example:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement