无法在Eclipse中使用XPath中的变量--Selenium [英] Unable to use Variable in XPath in Eclipse - Selenium

查看:222
本文介绍了无法在Eclipse中使用XPath中的变量--Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Excel中的值(存储在变量api中)传递给eclipse中的XPATH(java - Selenium)。



我尝试了几个选项,但没有任何作用。请指导。



这是我的代码行。

  String appcode = // input [contains(@ id,'app')and contains(@ type,'text')and ancestor :: div [contains(@id,'+ api +')]] 

当我硬编码api的价值如下所示:

  String appcode =// input [contains(@ id,'app')and contains(@ type,'text')and ancestor :: div [contains(@id,'setmember' ]]; 

这不容易吗?



欣赏你的帮助



pk

解决方案

你可能没有结束String构造函数正确。尝试这样:

  String appcode =//输入[包含(@ id,'app')并包含(@type, 'text')和ancestor :: div [contains(@id,'+ api +')]]; 

我的假设是, api 变量是键入 String


I need to pass values from excel sheet ( stored in variable api ) to XPATH in eclipse (java - Selenium).

I tried several options but none works. Please guide.

Here is my line of code.

String appcode = //input[contains(@id,'app') and contains(@type,'text') and ancestor::div[contains(@id, '+api+')]]

When i hardcode the value of api as below it works.

String appcode="//input[contains(@id,'app') and contains(@type,'text') and ancestor::div[contains(@id, 'setmember')]]";

Isnt it this easy?

Appreciate your help

pk

解决方案

you probably did not end the String constructor properly. Try this:

String appcode = "//input[contains(@id,'app') and contains(@type,'text') and ancestor::div[contains(@id, '" +api+" ')]]";

My assumption is, that api variable is type String

这篇关于无法在Eclipse中使用XPath中的变量--Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆