首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误- NotImplementedException未被处理

错误- NotImplementedException未被处理
EN

Stack Exchange QA用户
提问于 2017-05-17 10:11:49
回答 1查看 193关注 0票数 1

我试图减去两个变量的结果,我想在Selenium中回显结果。

我正在使用VS2015作为我的IDE。

代码语言:javascript
复制
//Obtaining pressure For 2100 hours today
driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[16]")).Click();
    
//Obtain pressure for 2200 Hours tomorrow
driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[7]")).Click();
    
//Subtract the two values above and then 'echo' the result in Selenium
int var2 = 1014;
    
var2 - var1 = 

代码的最后一部分是我需要帮助的地方,请。

有什么想法吗?

这里是代码:

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Support.UI;

namespace BBC_W_FCast_New_01
{
    class Program
    {
        static void Main(string[] args)
        {
            //Instantiate Firefox Driver
            var driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://www.bbc.co.uk/weather");

            //Using the 'Find a Forecast' search field to get the weather in 'Reading, UK'
            var user = driver.FindElement(By.Id("locator-form-search"));

            //Use "Reading, Reading" to avoid ambiguity. There is a location called Reading in USA
            user.SendKeys("Reading, Reading");

            //Click on Search button
            driver.FindElement(By.Id("locator-form-submit")).Click();

            //WebDriver Wait
            //Trial Code 1 - WebDriverWait wait = new WebDriverWait(driver, 30);
            //Trial Code 2 - wait.until(ExpectedConditions.visibilityOfElementLocated(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[10]")));

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            IWebElement element = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("detail-table-view")));

            //Click on Table button
            driver.FindElement(By.Id("detail-table-view")).Click();

            //Obtaining pressure For 2100 hours today
            driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[10]")).Click();
                                                     
            //Obtain pressure for 2100 Hours tomorrow
            driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[16]")).Click();

            //Subtract the two values above and then 'echo' the result in Selenium
            int val1 = Int32.Parse(driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[16]")).Text);
            int val2 = Int32.Parse(driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[10]")).Text);

            int difference = val1 - val2;
System.Console.WriteLine("Difference is: " + difference);
        }
    }

    internal class WebDriverWait
    {
        private FirefoxDriver driver;
        private TimeSpan timeSpan;

        public WebDriverWait(FirefoxDriver driver, TimeSpan timeSpan)
        {
            this.driver = driver;
            this.timeSpan = timeSpan;
        }

        internal IWebElement Until(object p)
        {
            throw new NotImplementedException();[![Error - NotImplementedException Was Unhandled][1]][1]

错误截图:

EN

回答 1

Stack Exchange QA用户

发布于 2017-05-18 09:40:34

前两个driver.FindElement只需单击单元格;您可能也希望查询它们的内容:

代码语言:javascript
复制
`var cell16 = driver.FindElement(By.XPath(".//*[@id='hourly']/div[3]/table/tfoot/tr[3]/td[16]")).Text();`

在此之后,您将进行减法:

代码语言:javascript
复制
var result = cell16 + cell07;

Console.WriteLine(result);

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

https://sqa.stackexchange.com/questions/27302

复制
相关文章

相似问题

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