【问题标题】:How to call the string value to the void function如何将字符串值调用到void函数
【发布时间】:2022-12-06 19:22:12
【问题描述】:
[Test]
        public void start()
        {
            string link = "https://www.w3schools.com/";
             //i want to call this link in below test case
        }

[Test]
        public void CC1()
        {
            IWebDriver driver = new ChromeDriver();
            WebDriverWait _wait = new WebDriverWait(driver, TimeSpan.FromSeconds(90));
            InitialLogin(driver, _wait);
            string url = start();//here i am calling this function
            driver.Navigate().GoToUrl(url);//here i want the above link
        }

我收到的错误信息是 无法将类型“void”隐式转换为“string”

【问题讨论】:

    标签: c# selenium selenium-webdriver automated-tests


    【解决方案1】:

    您的问题是您已将启动方法标记为测试并为其指定返回类型 void

    如下更改方法将解决您的问题:

    private string start()
    {
        //I want to call this link in below test case
        return "https://www.w3schools.com/";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多