2017-08-29 69 views
-1

我已经做了一些使用硒的测试。我在visual studio 2015中创建了我的解决方案,所有的测试都运行良好,但是当我在visual studio 2017中运行我的测试时,除了需要右键单击时,我的所有测试都可以工作。上下文点击(右键)不工作visual studio 2017

我不知道这是为什么在Visual Studio中只发生了2017年

我得到一个运行时错误说,元素为null但是在行之前我试着右击我可以左键单击元素所以我知道这个元素不是null。

我的代码如下

var webDriverWait = new WebDriverWait(session, TimeSpan.FromSeconds(10)); 
     Actions action = new Actions(session); 

     CommonMethods.switchWindows(session); 
     CommonMethods.keyCheck(session); 
     Thread.Sleep(2000); 
     webDriverWait.Until(ExpectedConditions.ElementTo‌​BeClickable(session.FindElementByName($"{fileName} - PowerPoint"))).Click();     
     Thread.Sleep(2000); 
     webDriverWait.Until(ExpectedConditions.ElementTo‌​BeClickable(session.FindElementByName("Create"))).Click(); 
     webDriverWait.Until(ExpectedConditions.ElementTo‌​BeClickable(session.FindElementByName("View Links"))).Click(); 
     CommonMethods.IsElementDisplayed(session, new StackTrace(true).GetFrame(0).GetFileLineNumber(), new StackTrace(true).GetFrame(0).GetMethod(), "CreateErrorIcon", "Error appeard when selecting the View Links button"); 
     webDriverWait.Until(ExpectedConditions.ElementTo‌​BeClickable(session.FindElementByName("Create"))).Click(); 
     var e =webDriverWait.Until(ExpectedConditions.ElementTo‌​BeClickable(session.FindElementByName(SlideNumber))); 
     e.Click();    
     action.ContextClick(e).Perform(); 
     webDriverWait.Until(ExpectedConditions.ElementTo‌​BeClickable(session.FindElementByName(element))).Click(); 
     keyCheck(session); 
+0

您可以发布完整例外吗? – Guy

回答

-1

我想通了这个问题。出于某种原因,WinAppDriver的最新版本(2017年5月)不会上下文点击。下载2017年3月版本并解决问题

+0

它为我做了。必须得到我遇到的同样的问题? –