小编Roe*_*hen的帖子

如何使用selenium web-driver设置新的元素样式

我正在使用(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)

它不起作用....任何建议?

selenium selenium-webdriver

6
推荐指数
1
解决办法
2万
查看次数

查找字符串中最常见字符的更有效方法

我创建了一种方法来查找字符串中最常见的字符:

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)

java optimization

6
推荐指数
1
解决办法
5081
查看次数

标签 统计

java ×1

optimization ×1

selenium ×1

selenium-webdriver ×1