我想按一下按钮标记此选项的按钮:
<div aria-controllers="my-list"> Press for more information </div>
我应该使用哪种来自R selenium?
这就是我的尝试:
webElem1 <- remDr$findElement(using = 'aria-controllers', value = 'my-list')
webElem1$sendKeysToElement(list('R', key = 'enter'))
另外,如果我使用它,我收到以下错误:
webElem <- remDr$findElement(using = 'aria-controllers', value = "my-list")
Error in match.arg(using) :
'arg' should be one of “xpath”, “css selector”, “id”, “name”, “tag name”, “class name”, “link text”, “partial link text”
答案 0 :(得分:0)
我不知道R,但我认为你需要的是
// import preact
import { h, render, Component } from 'preact';
// import stylesheets for ipad & button
import style from './style';
import style_iphone from '../button/style_iphone';
// import jquery for API calls
import $ from 'jquery';
// import the Button component
import Button from '../button';
export default class Iphone extends Component {
//var Iphone = React.createClass({
// a constructor with initial set states
constructor(props){
super(props);
// temperature state
this.state.temp = "";
}
componentWillUpdate(){
this.fetchWeatherData();
}
// a call to fetch weather data via wunderground
fetchWeatherData = () => {
// API URL with a structure of :
ttp://api.wunderground.com/api/key/feature/q/country-code/city.json
var url =
"http://api.wunderground.com/api/mykey/conditions/q/UK/London.json";
$.ajax({
url: url,
dataType: "jsonp",
success : this.parseResponse,
error : function(req, err){ console.log('API call failed ' + err); }
})
}
// the main render method for the iphone component
render() {
// check if temperature data is fetched, if so add the sign styling to the page
const tempStyles = this.state.temp ? `${style.temperature} ${style.filled}` : style.temperature;
document.write(this.state.locate);
// display all weather data
return (
<div class={ style.container }>
<div class={ style.header }>
<div class={ style.city }>{ this.state.locate }</div>
<div class={ style.conditions }>{ this.state.cond }</div>
<span class={ tempStyles }>{ this.state.temp }</span>
</div>
<div class={ style.details }></div>
<div class= { style_iphone.container }>
{ this.state.display }
</div>
</div>
);
}
parseResponse = (parsed_json) => {
var location = parsed_json['current_observation']['display_location']['city'];
var temp_c = parsed_json['current_observation']['temp_c'];
var conditions = parsed_json['current_observation']['weather'];
// set states for fields so they could be rendered later on
this.setState({
locate: location,
temp: temp_c,
cond : conditions
});
}
第一个参数是定位器的类型,这就是为什么你得到错误列出所有定位器类型,如'id','css selector'等。我选择了一个CSS选择器因为我认为最符合你的方式试图找到元素。
第二个参数是定位器本身。在这种情况下,CSS选择器。
您可能应该花一些时间查看文档。
https://www.rdocumentation.org/packages/seleniumPipes/versions/0.3.7/topics/findElement