Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 映射元素不使用xpath_Ruby_Xpath_Automated Tests_Cucumber_Capybara - Fatal编程技术网

Ruby 映射元素不使用xpath

Ruby 映射元素不使用xpath,ruby,xpath,automated-tests,cucumber,capybara,Ruby,Xpath,Automated Tests,Cucumber,Capybara,我正在使用SitePrism,在这种情况下我遇到了困难,我不想使用xpath Ele esta maneira实施计划: 我只有在使用下面的xpath时才成功 element:btn_fechar,:xpath,'/*[@id=“main wrapper”]/header/nav/div[2]/ul[2]/li/a/img'如果没有更多的HTML结构来确保指定的内容与多个内容不匹配,就无法确定什么CSS选择器适用于您。猜测可能是这样的 element :btn_fechar, :css, 'im

我正在使用SitePrism,在这种情况下我遇到了困难,我不想使用xpath

Ele esta maneira实施计划

我只有在使用下面的xpath时才成功


element:btn_fechar,:xpath,'/*[@id=“main wrapper”]/header/nav/div[2]/ul[2]/li/a/img'

如果没有更多的HTML结构来确保指定的内容与多个内容不匹配,就无法确定什么CSS选择器适用于您。猜测可能是这样的

element :btn_fechar, :css, 'img.profile-pic'
element :btn_fechar, :css, '#main-wrapper img.profile-pic'
element :btn_fechar, :css, '#main-wrapper header img.profile-pic'
尽管根据您为元素使用的名称判断,您可能实际上希望找到
a
元素,该元素实际上是“按钮”--您在此处没有提供足够的信息来确定如何识别该元素,但假设您遵循了合理的做法,并且在
a
元素上有
title
属性,您可以执行以下操作

element :btn_fechar, :link, 'title attribute value'

使用XPath有什么问题?