小编kil*_*erd的帖子

initMocks上的Mockito AbstractMethodError

所以我整天都在努力让Mockito为我的Android项目工作.我在Gradle构建文件中添加了所有内容:

androidTestCompile 'org.mockito:mockito-core:2.0.29-beta'
androidTestCompile "junit:junit:4.12-beta-3"
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
Run Code Online (Sandbox Code Playgroud)

并尝试运行一个没有真正做任何事情的测试:

@RunWith(MockitoJUnitRunner.class)
public class LoginActivityTest extends 
    ActivityInstrumentationTestCase2<LoginActivity> {

    private LoginActivity loginActivity;

    private EditText et_email;
    private EditText et_password;
    private Button btn_login;

    @Mock
    SpiceManager manager;

    public LoginActivityTest(){
        super(LoginActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        loginActivity = getActivity();

        MockitoAnnotations.initMocks(this);
        //manager = mock(SpiceManager.class);
        loginActivity.spiceManager = manager;

        et_email = (EditText) loginActivity.findViewById(R.id.et_email);
        et_password = (EditText) loginActivity.findViewById(R.id.et_password);
        btn_login = (Button) loginActivity.findViewById(R.id.btn_login);
    }

    @Override
    public void tearDown() throws Exception {
        super.tearDown();
    }

    public void testLoginEmpty() throws …
Run Code Online (Sandbox Code Playgroud)

testing android unit-testing mockito

12
推荐指数
3
解决办法
6715
查看次数

通用winphone authentication_ui_failed with ADAL

所以这整个adal事情是一个巨大的痛苦才能正常工作......每当我尝试使用其中一个身份提供程序(通过ADAL安装并由azure AD后端提供)登录时,windows phone会抛出"authentication_ui_failed"异常.

我一直在四处寻找和谷歌搜索几天,但一直没有找到任何有用的东西.我正在使用ADAL的预发布版本可能没有帮助...

无论如何,这是发生的事情:

  1. 点击登录(开始流程)
  2. Windows Phone停止显示当前应用程序(屏幕变黑并加载一段时间)
  3. 将出现一个新屏幕,其中包含安装在后端的身份提供程序(Facebook,Google +,...)
  4. 点击Facebook或谷歌或其他什么,它会带你到相关的登录页面
  5. 输入凭据并按登录
  6. 当设备尝试返回应用程序时,屏幕再次变黑
  7. "恢复"在屏幕上显示一瞬间
  8. 抛出异常

例外是:

authentication_ui_failed:基于浏览器的身份验证对话框无法完成.

内在异常:

System.IO.FileNotFoundException: The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.WebUI.<AcquireAuthorizationAsync>d__0.MoveNext() 
Run Code Online (Sandbox Code Playgroud)

和stacktrace:

at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.WebUI.<AcquireAuthorizationAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.AcquireTokenInteractiveHandler.<AcquireAuthorizationAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at …
Run Code Online (Sandbox Code Playgroud)

azure adal win-universal-app

5
推荐指数
0
解决办法
228
查看次数

使用for-each循环遍历页面时的selenium stale元素

我一直在尝试制作一个与网站互动的小程序(更精确的浏览器游戏),从不同页面获取一些信息并将其打印到GUI.

我打印工作正常,我可以登录没有问题,并导航网站.但是当我尝试获取我需要的数据时(使用for-each循环完成),selenium不断抛出"元素似乎过时"错误并终止应用程序.

我从第一个星球上得到了数据,但这就是它结束的地方.这是代码片段:

public void getResources()
    {
        List<WebElement> planets = driver.findElements(By.className("smallplanet"));
        String name;
        int metal;
        int crystal;
        int deuterium;
        int energy;
        boolean firstPlanet = true;

        for(WebElement planet : planets)
        {       
            if(!firstPlanet)
            {
                WebElement tag = planet.findElement(By.tagName("a"));
                tag.click();
            } else
            {
                firstPlanet = false;
            }

            name = planet.findElement(By.className("planet-name")).getText();
            System.out.println(name);
            metal = Integer.parseInt(driver.findElement(By.id("resources_metal")).getText().replace(".", ""));
            crystal = Integer.parseInt(driver.findElement(By.id("resources_crystal")).getText().replace(".", ""));
            deuterium = Integer.parseInt(driver.findElement(By.id("resources_deuterium")).getText().replace(".", ""));
            energy = Integer.parseInt(driver.findElement(By.id("resources_energy")).getText().replace(".", ""));        

            resources.add(new ResourceLine(name, metal, crystal, deuterium, energy));
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是错误:

Element appears to be stale. Did you …
Run Code Online (Sandbox Code Playgroud)

javascript java selenium

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