小编Mos*_*hta的帖子

在Selenium Grid中设置IE6(和多个浏览器)

我很难尝试掌握selenium Grid/RC的一些概念.我需要的是为测试提供特定的环境(即6-on-xp,即7-on-xp等).因为我一直在读什么,在浏览器行grid_configuration.yml不作什么版本的任何参考MSIEFirefox我跑.所以我无法理解以哪种形式告诉Grid/RC我想要一些特定的浏览器和运行它们的路径(RC如何知道运行哪个exe?)

其次,我想运行这些浏览器的便携版本.我只看到了测试中指定的那个,而不是在RC的命令行中运行它们.这是每次测试的方法吗?

selenium selenium-grid selenium-rc

3
推荐指数
1
解决办法
3615
查看次数

使用量角器和selenium将文件上传到隐藏输入

我有一个隐藏的文件输入字段,如下所示:

<input type="file" id="fileToUpload-1827" multiple="" onchange="angular.element(this).scope().setFiles(this)" data-upload-id="1827" class="hidden-uploader">
Run Code Online (Sandbox Code Playgroud)

我希望能够将文件上传到此.在量角器中执行此操作的常规方法是:

ptor.findElement(protractor.By.css('.file-upload-form input')).sendKeys('/path/to/file')
Run Code Online (Sandbox Code Playgroud)

但由于输入元素不可见,我收到错误.

我试过了:

  ptor.driver.executeScript("return $('.file-upload-form input')[0].removeClass('hidden-uploader');").then(function () {
    ptor.findElement(protractor.By.css('.file-upload-form input')).sendKeys('hello');
  })
Run Code Online (Sandbox Code Playgroud)

但得到了错误

UnknownError: $(...)[0].removeClass is not a function
Run Code Online (Sandbox Code Playgroud)

使用executeScript一个元素可见以便我可以上传文件似乎很荒谬,有更好的方法吗?如果没有,我该如何取消隐藏元素?

输入表单的完整html是:

<form class="file-upload-form ng-scope ng-pristine ng-valid" ng-if="ajaxUploadSupported">
<strong>Drag files here to upload</strong> or

<label for="fileToUpload-1953">
  <div class="btn btn-info select-file-btn">
    Click to Select
  </div>
</label>

<div>
      <input type="file" id="fileToUpload-1953" multiple="" onchange="angular.element(this).scope().setFiles(this)" data-upload-id="1953" class="hidden-uploader">
</div>
</form>
Run Code Online (Sandbox Code Playgroud)

selenium protractor

3
推荐指数
1
解决办法
5504
查看次数

尝试使用selenium webdriver在linux上启动chrome驱动程序

我试着找到答案而不能,现在我自己问.

我写了简单的测试

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r"/home/tranter/workspace/chromedriver")
driver.get("http://www.python.org")
driver.close()
Run Code Online (Sandbox Code Playgroud)

比我有追溯

> tranter@tranter-VirtualBox:~/workspace$ python testchrome.py Traceback
> (most recent call last): File "testchrome.py", line 6, in <module>
> driver =
> webdriver.Chrome(executable_path=r"/home/tranter/workspace/chromedriver")
> File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py",
> line 65, in __init__ keep_alive=True) File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 73, in __init__ self.start_session(desired_capabilities,
> browser_profile) File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 121, in start_session 'desiredCapabilities':
> desired_capabilities, File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 173, in execute self.error_handler.check_response(response) File
> "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py",
> line 166, …
Run Code Online (Sandbox Code Playgroud)

python linux selenium selenium-chromedriver

3
推荐指数
2
解决办法
7842
查看次数

Selenium WebDriver IE性能

_driver.FindElement(By.CssSelector("[id='3_NewSiteMaintenanceButton']"));
Run Code Online (Sandbox Code Playgroud)

= 15.0s


_driver.FindElement(By.CssSelector("[id$='NewSiteMaintenanceButton']"));
Run Code Online (Sandbox Code Playgroud)

= 18.4s


_driver.FindElement(By.CssSelector("#3_NewSiteMaintenanceButton"));
Run Code Online (Sandbox Code Playgroud)

NoSuchElementException:无法使用css选择器找到元素==#3_NewSiteMaintenanceButton


_driver.FindElement(By.Id("3_NewSiteMaintenanceButton"));
Run Code Online (Sandbox Code Playgroud)

= 12.58s


Chrome和FireFox 分别在4秒和6秒内完成整个测试,而IE需要12-18秒才能找到单个DOM元素.为什么IE这么慢,我怎样才能提高性能呢?

c# selenium css-selectors selenium-webdriver

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

如何从警报框中获取文本

我需要从下面显示的警告框中获取文本.此警告框显示悬停在网址栏上方.下面是我的框架断言的一个例子:

verifyDisplay("'"+ driver.switchTo().alert().getText() + "'", By.xpath("xpath").
Run Code Online (Sandbox Code Playgroud)

我不知道,如何抓住xpath,id,name这个警告框,因为是没有的.

任何帮助是极大的赞赏.

在此输入图像描述

selenium selenium-webdriver

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

Java异常抛出对象并从catch获取对象

我想在获取异常并从catch获取时传递对象.我UserDataException从Exception扩展

throw new UserDataException("Media uploaded failed",mediaDO, dupkExp);
Run Code Online (Sandbox Code Playgroud)

mediaDO 是对象.

如果可能的话,mediaDocatch声明中获取此对象

catch (UserDataException uExp) {

    }
Run Code Online (Sandbox Code Playgroud)

UserdataException calss:

public class UserDataException extends Exception {

private static final String ERROR = "Database Transaction Error: ";
private static final String DKERROR = "Duplicate Key Error";

/**
 * 
 */
private static final long serialVersionUID = 6209976874559850953L;

/**
 * 
 */
public UserDataException(String message, Throwable throwable) {
    super(message, throwable);
}

public UserDataException(String message) {
    super(message);
}

/**
 * <code>UserDataException</code> thrown …
Run Code Online (Sandbox Code Playgroud)

java

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

MockitoAnnotations.Mock类型已弃用

我正在使用@Mock注释来模拟对象

@Mock
Customer customer;
Run Code Online (Sandbox Code Playgroud)

@Mock注释显示警告

MockitoAnnotations.Mock类型已弃用

我的测试用例失败了

java junit mockito powermock

2
推荐指数
2
解决办法
2685
查看次数

春季格式错误的“成员”属性值

我正在创建一个必须连接到活动目录的应用程序。

在处理组成员更新时,我实际上遇到了一个问题。

群组名称是:GG-Collaboration-AgenceXXX

GroupRepository是抛出异常的我的类代码:

 public void addMemberToGroup(String groupName, User user) {
        Name groupDn = this.buildGroupDn(groupName);
        Name userDn = this.buildPersonDn(user.getFirstName() + " " + user.getLastName(), user.getCompany(), user.getCountry().toString());
        DirContextOperations ctx = this.ldapTemplate.lookupContext(groupDn);
        ctx.addAttributeValue("member", userDn);
        System.out.println(userDn);
        this.ldapTemplate.modifyAttributes(ctx);
    }

 private Name buildGroupDn(String groupName) {
        return LdapNameBuilder.newInstance("CN=" + groupName).build();
    }

    private Name buildPersonDn(String fullname, String company, String country) {
        return LdapNameBuilder.newInstance("DC=test,DC=lan").add("OU", "Utilisateurs").add("CN", fullname).build();
    }
Run Code Online (Sandbox Code Playgroud)

这是我的全栈错误:

Malformed 'member' attribute value; nested exception is javax.naming.directory.InvalidAttributeValueException: Malformed 'member' attribute value; remaining name 'CN=GG-Collaboration-AgenceXXX'
    at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:132) …
Run Code Online (Sandbox Code Playgroud)

java spring ldap active-directory

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

无法从方法中获取@override 注释

当我从class实例中获取方法并想要获取@override注释时。但是方法没有任何注释。获得@override 注解是不可能的吗?

代码如下。

package com.test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import javax.annotation.Resource;

public class ReflectionTest {

    public static void main(String[] args) throws Exception {
        ChildHoge childHoge = new ChildHoge();
        Method method = childHoge.getClass().getMethod("init");
        for (Annotation s : method.getAnnotations()) {
            System.out.println(s);
        }
        Method method2 = childHoge.getClass().getMethod("a");
        for (Annotation a : method2.getAnnotations()) {
            System.out.println(a); // =>@javax.annotation.Resource(mappedName=, shareable=true, type=class java.lang.Object, authenticationType=CONTAINER, lookup=, description=, name=)

        }
    }

}

class SuperHoge {
    public void init() {

    }
}


class ChildHoge extends …
Run Code Online (Sandbox Code Playgroud)

java annotations

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

在方法中使用@SuppressWarnings会生成编译错误

我有以下代码块:

     final Map<String, Double> map;
            if (cond) {
                int currency = 44;
                @SuppressWarnings("unchecked")
                map = (Map<String, Double>)objectA.get();
            }else {
                map= ....}
Run Code Online (Sandbox Code Playgroud)

get()objectA返回raw的方法HashMap(我知道在那里使用泛型会很好,我的问题会解决,但我无法更改该类的代码).如果我删除 @SuppressWarnings("unchecked")线路,显然我会收到TypeSafety警告.但是当我在线下添加supress警告时,我得到以下错误:

map cannot be resoved to a type!
Run Code Online (Sandbox Code Playgroud)

有人能解释我为什么吗?

java generics compiler-errors

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