zoukankan      html  css  js  c++  java
  • C# selenium环境配置

    1.下载C#selenium
     
     
    下载后解压:
     
     
    打开net35后,将里面的dll文件添加到ranorex中;
    2.浏览器环境配置

    将需要用到的浏览器chrome,firfox,等exe所在的文件

    夹添加到系统变量path中去,必要的时候需要重启电脑;

    这一步很重要,否则运行下面的脚本打开不了浏览器,需要在脚本中添加浏览器地址
     
    3.本地运行脚本;
    using Selenium;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    public void Test001()
            {
                  IWebDriver selenium = new ChromeDriver();
                  selenium.Navigate().GoToUrl("http://www.baidu.com/");
                  //selenium.FindElement();
            }
     
    4.在远程机执行remoting
    远程机环境配置:
    • 需要将浏览器添加到系统变量path中
    • 需要下载selenium-server-standalond.jar
    • 然后再cmd或者windows PowerShell中进入到selenium-server-standalond.jar所在的文件夹,执行命令,打开服务,命令如下
    • PS C:Userscpr018Desktopselenium> java -jar selenium-server-standalone.jar
    • 在客户端运行脚本,即可在远程执行测试脚本
    • remoting其他详细设置请看 http://www.cnblogs.com/tanghuang/p/6829258.html
     
    客户端脚本:
     
    using Selenium;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    public static void test001()
            {
                  //uri中的ip为远程机的ip,开启服务默认端口为4444
                  var driver = new RemoteWebDriver(new Uri("http://192.168.226.131:4444/wd/hub"), DesiredCapabilities.Chrome());
                  driver.Navigate().GoToUrl("http://www.baidu.com/");
     
     
             }
     
     
     
  • 相关阅读:
    MAVEN[08]
    MAVEN[04]
    hdu 1757【A Simple Math Problem】
    hdu 1507【Uncle Tom's Inherited Land*】
    hdu 2768【Cat vs. Dog】
    hdu 1392【Surround the Trees】
    hdu 1348【wall】
    hdu 2824【The Euler function】
    hdu 1147【Pickup sticks】
    hdu 1528【Card Game Cheater】
  • 原文地址:https://www.cnblogs.com/tanghuang/p/6829248.html
Copyright © 2011-2022 走看看