我正在使用(selenium webdriver-java)为包含打开小颜色选择窗口的按钮的页面构建测试计划.
这是颜色选择窗口右侧面板的代码:
<span class="ui-colorpicker-bar-layer-pointer">
<span class="ui-colorpicker-bar-pointer" style="top: 51.0333px;"></span>
Run Code Online (Sandbox Code Playgroud)
问题是我如何设置新的风格.....,我找到了这个解决方案:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('colorPickIcon').setAttribute('style', '22.3333px')");
Run Code Online (Sandbox Code Playgroud)
它不起作用....任何建议?
我创建了一种方法来查找字符串中最常见的字符:
public static char getMax(String s) {
char maxappearchar = ' ';
int counter = 0;
int[] charcnt = new int[Character.MAX_VALUE + 1];
for (int i = 0 ; i < s.length() ; i++)
{
char ch = s.charAt(i);
// increment this character's cnt and compare it to our max.
charcnt[ch]++ ;
if (charcnt[ch] >= counter)
{
counter = charcnt[ch];
maxappearchar = ch;
}
}
System.out.println("the max char is " +maxappearchar + " and displayed " +counter+ " times");
return …
Run Code Online (Sandbox Code Playgroud)