做循环和预期条件 - 可以一起使用吗?(Do While Loop and ExpectedConditions - Possible to use together?)
做循环和预期条件 - 可以一起使用吗?
- 我得到奇怪的无法找到元素/超时异常与下面列出的方法。
2.是否可以添加while循环,以便该方法可以多次检查和执行?
public void waitAndClickElement(WebElement element) throws InterruptedException { try { this.wait.until(ExpectedConditions.elementToBeClickable(element)).click(); System.out.println("Successfully clicked on the WebElement: " + "<" + element.toString() + ">"); }catch (Exception e) { System.out.println("Unable to wait and click on WebElement, Exception: " + e.getMessage()); Assert.assertFalse(true, "Unable to wait and click on the WebElement, using locator: " + "<" + element.toString() + ">"); } }
Do While Loop and ExpectedConditions - Possible to use together?
- Iam getting the odd unable to locate element / timeout exception with the method listed below.
2. Is it possible to add a while loop so the method can check and execute more than once?
public void waitAndClickElement(WebElement element) throws InterruptedException { try { this.wait.until(ExpectedConditions.elementToBeClickable(element)).click(); System.out.println("Successfully clicked on the WebElement: " + "<" + element.toString() + ">"); }catch (Exception e) { System.out.println("Unable to wait and click on WebElement, Exception: " + e.getMessage()); Assert.assertFalse(true, "Unable to wait and click on the WebElement, using locator: " + "<" + element.toString() + ">"); } }
原文:https://stackoverflow.com/questions/42483776
最满意答案
使用Jon Skeet提供的lambda。 也许他也可以解释为什么
ParameterExpression
使用起来非常痛苦并且需要使用相同的实例,而不是能够通过名称匹配:)修改此行:
Type[] exprArgTypes = { query.ElementType };
exprArgTypes
是类型参数IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate).
正如您所看到的,它只有一个类型参数 -
TSource
,即Purchase
。 你有效地做了什么,调用Where
方法有两个类型参数,如下所示:IQueryable<Purchase> Where<Purchase, bool>(this IQueryable<Purchase> source, Expression<Func<Purchase, bool>> predicate)
一旦这两个修复程序都在表达式运行中没有问题。
Use the lambda that Jon Skeet supplied. Perhaps he can also explain why
ParameterExpression
is so painful to use and requires using the same instance, instead of being able to be matched by name :)Modify this line:
Type[] exprArgTypes = { query.ElementType };
exprArgTypes
is type parameters toIQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate).
As you can see it only has one type parameter -
TSource
, which isPurchase
. What you were doing, effectively, was callingWhere
method with two type parameters like below:IQueryable<Purchase> Where<Purchase, bool>(this IQueryable<Purchase> source, Expression<Func<Purchase, bool>> predicate)
Once both of those fixes are in the expression runs with no problem.
相关问答
更多-
使用“提供的参数”在Queryable上找不到OrderBy。(Can't find OrderBy on Queryable with the “supplied arguments”.)[2022-11-17]
由于您希望您的属性选择器表达式动态地进行适当的调用,因此您必须为其创建新的表达式。 你不能直接使用提供的选择器,因为它目前是键入Expression>并且不返回特定类型Expression > 。 你可以通过改变调用的类型参数来接受object来编译它,但它不会像预期的那样工作,因为它会做对象引用比较(并且你的LINQ提供者可能会拒绝它)。 要重新创建选择器表达式,可以这样做: private static IQueryable Bui ... -
context.Products.Where(predicate)中的context.Products.Where(predicate)显然只能是Expression
> ,而不是Expression > ,因为不能保证T是Product 。 您正尝试过滤目标类型的谓词,而过滤必须在源类型上进行: public ICollection GetProductsByMatching (Expression 我的类型定义与错误建议的位置错误。 typeof(TSource)必须是typeof(TNav),因为我们正在订购source.Gifts。 My type definitions where wrong as the error suggested. typeof(TSource) had to be typeof(TNav) since we are ordering source.Gifts.SelectMany接受一个对象集合,每个对象都有一个集合属性。 您在第一个语句中选择了APPLICANTs集合,并在其上运行SelectMany似乎没有意义。 查看这些链接以更好地了解SelectMany。 http://msdn.microsoft.com/en-us/library/bb534336.aspx Select和SelectMany之间的区别 SelectMany accepts a collection of object which each of them have a collec ...从表达式调用方法(Calling a Method from an Expression)[2022-10-31]
我在尝试获取string.Contains时遇到了类似的问题。 string.Contains工作; 我只是使用了GetMethod / MethodInfo方法; 然而 - 它很复杂,因为它是一种通用方法...... 这应该是正确的MethodInfo - 但是如果Tank和Vehicle没有更多的清晰度,很难给出一个完整的(可运行的)答案: MethodInfo method = typeof(Queryable).GetMethods() .Where(m => m.Name = ...问题是您正在生成实际基础类型的函数的表达式,而不是源表达式( object )的类型。 您需要在生成的表达式中为您的类型添加转换。 public static IQueryable使用Jon Skeet提供的lambda。 也许他也可以解释为什么ParameterExpression使用起来非常痛苦并且需要使用相同的实例,而不是能够通过名称匹配:) 修改此行: Type[] exprArgTypes = { query.ElementType }; exprArgTypes是类型参数 IQueryableWhere (this IQueryable source, Expression > ... 我更喜欢使用MethodInfo对Expression.Call进行不同的重载,这是一个我工作的简单示例。 Expression constant = Expression.Constant(new string[] { "a", "b" }); MethodInfo methodInfo = typeof(Enumerable).GetMethods().FirstOrDefault(c => (c as MethodInfo).Name == "DefaultIfEmpty"); methodInfo ...这现在是Kendo UI的一个已知问题,将由Kendo UI团队修复 This is now an known issue with Kendo UI and will be fixed by the Kendo UI team这是最初的问题,我想: Expression.Lambda>(predicateBody, new ParameterExpression[] { pe1, pe2 })) Func 只接受一个string并返回一个bool 。 所以它只有一个参数。 你传递了两个 ParameterExpressions 。 而且,它们都是 int参数......不是一个字符串! 所 ... 相关文章
更多- Lua循环遍历
- solr实现满足指定距离范围条件的搜索
- 关于不定条件写法的问题
- (转载)solr实现满足指定距离范围条件的搜索
- java WHILE 循环问题
- Java循环结构 – for, while 及 do…while
- Groovy 条件语句
- bash shell循环的疑问
- Linux内核Bridge代码的STP的实现(转)
- Groovy 循环语句
最新问答
更多- h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
- 创建一个功能(Create a function)
- 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
- PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
- Qt冻结循环的原因?(Qt freezing cause of the loop?)
- TableView重复youtube-api结果(TableView Repeating youtube-api result)
- 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
- SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
- 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
- 以编程方式创建UITableView(Creating a UITableView Programmatically)
- 如何打破按钮上的生命周期循环(How to break do-while loop on button)
- C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
- 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
- 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
- Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
- 设置kotlin扩展名(Setting a kotlin extension)
- 如何并排放置两个元件?(How to position two elements side by side?)
- 如何在vim中启用python3?(How to enable python3 in vim?)
- 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
- 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
- Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
- dedecms如何安装?
- 在哪儿学计算机最好?
- 学php哪个的书 最好,本人菜鸟
- 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
- 如何覆盖错误堆栈getter(How to override Error stack getter)
- 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
- USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
- 电脑高中毕业学习去哪里培训
- 正则表达式验证SMTP响应(Regex to validate SMTP Responses)