首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要有关Desiredcapabilities类的帮助

需要有关Desiredcapabilities类的帮助
EN

Stack Overflow用户
提问于 2014-07-13 20:24:20
回答 3查看 369关注 0票数 1

您好,我是第一次学习selenium网格,我不明白为什么要使用Desired capabilities类在远程机器上设置浏览器名称和平台详细信息。

除了google-wiki页面,请让我知道是否有任何适当的文档

感谢prathima

EN

回答 3

Stack Overflow用户

发布于 2014-07-13 21:59:58

并非所有远程机器(或会话)都支持用户请求的功能。例如,用户可能想在Windows上使用Chrome,但有些机器只在Linux上运行Firefox。

desiredCapabilities用于描述用户请求的会话的特性。你可以参考this linkthis link获取更多信息。

票数 0
EN

Stack Overflow用户

发布于 2015-03-31 14:10:43

代码语言:javascript
复制
 - when user send request to remote machine to run a particular test on
   a particular browser on a particular platform.
 - It doesn't mean that all the remote machine will support all the
   features requested by user such as (Particular browser on a
   particular machine).

**Example:**

 - If user request to execute a testcase on internet explorer on Linux
   platform. It doesn't mean that always Linux machine has internet
   explorer it would have firefox not internet Explorer(Because it is
   open source).
 - Linux machine doesn't support the features requested by a User. so
   that, that point of time we will use DesiredCapabilites class to set
   the platform , Browser Name and version of browser of Remote Machine
   to execute the Test.
票数 0
EN

Stack Overflow用户

发布于 2015-03-31 14:26:03

代码语言:javascript
复制
Example:

package grid;

import static org.junit.Assert.*;

import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class SimpleGridTest
{
    WebDriver driver;
    String baseUrl , nodeUrl;

    @Before
    public void setUp() throws Exception 
    {
        WebDriver driver;
        String baseUrl , nodeUrl;
        baseUrl = "https://www.facebook.com";
        nodeUrl = "http://192.168.10.21:5568/wd/hub";

        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setBrowserName("firefox");
        capability.setPlatform(Platform.WIN8_1);


        driver = new RemoteWebDriver(new URL(nodeUrl),capability);
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);
    }


    @Test
    public void test() throws InterruptedException
    {
        driver.manage().window().maximize();
        driver.get("https://www.google.co.in");

        driver.findElement(By.linkText("Gmail")).click();
        driver.findElement(By.id("Email")).sendKeys("abc@gmail.com");

        driver.findElement(By.id("Passwd")).sendKeys("1234");

        driver.findElement(By.id("signIn")).click();
    }

    @After
    public void tearDown() throws Exception 
    {
        driver.quit();
    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24722668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档