我正在制作一个 html 表格,我需要某些框的背景在 selenium webdriver 运行后更改颜色。例如,如果 webdriver 在整个站点上运行时没有错误,它将将该应用程序表中的框更改为绿色,或者如果出现错误,则将框颜色更改为红色。我知道为此我需要 java 脚本,但我以前从未使用过它。
最佳答案
您可以使用 JavaScript 属性 document.body.style.background
。
这是一个例子:
function changeBackground(color) {
document.body.style.background = color;
}
查看此处了解更多信息:How do I change the background color with JavaScript?
例如,要在用户按下回车键时更改框的背景颜色,请单击:Changing background color of text box input not working when empty .
确实,您需要适应自己的元素。
关于javascript - 当发生特定事件时,如何更改 html 表格条目背景的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24370880/