我试图让Selenium点击一个单选按钮。 Selenium无法选择任何单选按钮,因为单选按钮的id
和name
是相同的。
我正在添加以下html
代码:
<label for="gender">Gender</label>
<input id="gender " name="gender" value="M" type="radio"/>
Male
<input id="gender " name="gender" value="F" type="radio"/>
Female
<label class="error" for="gender"/>
答案 0 :(得分:0)
请尝试以下代码。
如果您想点击 if (firstFrame) {
AVDictionary *opts = NULL;
av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov+default_base_moof", 0);
if(!parseSPSPPS(data, length)) {
return;
}
cout << "spslen " << spslen << " ppslen " << ppslen << endl;
auto c = st->codecpar;
// Extradata contains PPS & SPS for AVCC format
int extradata_len = 8 + spslen + 1 + 2 + ppslen;
c->extradata = (uint8_t*)av_mallocz(extradata_len);
c->extradata_size = extradata_len;
c->extradata[0] = 0x01;
c->extradata[1] = sps[1];
c->extradata[2] = sps[2];
c->extradata[3] = sps[3];
c->extradata[4] = 0xFC | 3;
c->extradata[5] = 0xE0 | 1;
int tmp = spslen;
c->extradata[6] = (tmp >> 8) & 0x00ff;
c->extradata[7] = tmp & 0x00ff;
int i = 0;
for (i=0; i<tmp; i++) {
c->extradata[8 + i] = sps[i];
}
c->extradata[8 + tmp] = 0x01;
int tmp2 = ppslen;
c->extradata[8 + tmp + 1] = (tmp2 >> 8) & 0x00ff;
c->extradata[8 + tmp + 2] = tmp2 & 0x00ff;
for (i=0; i<tmp2; i++) {
c->extradata[8 + tmp + 3 + i] = pps[i];
}
int ret = avformat_write_header(ctx, &opts);
if(ret < 0) {
return;
}
firstFrame = false;
}
AVPacket pkt;
av_init_packet(&pkt);
pkt.buf = av_buffer_alloc(length);
memcpy(pkt.buf->data, data, length);
pkt.buf->size = length;
pkt.data = pkt.buf->data;
pkt.size = pkt.buf->size;
pkt.pts = ts;
pkt.dts = ts;
if (keyFrame) {
pkt.flags |= AV_PKT_FLAG_KEY;
}
else {
pkt.flags = 0;
}
pkt.stream_index = st->id;
av_interleaved_write_frame(ctx, &pkt);
av_buffer_unref(&pkt.buf);
av_packet_unref(&pkt);
,请使用Male
定位器使用以下代码..
xpath
OR
如果您想点击WebElement radio_male = driver.findElement(By.xpath("//input[@value='M']"));
radio_male.click();
单选按钮,请使用Female
定位器使用以下代码。
xpath
xpath的说明: - 使用WebElement radio_female = driver.findElement(By.xpath("//input[@value='F']"));
radio_female.click();
标记的value
属性。
答案 1 :(得分:0)
Boolean btnSelected = odriver.findElement(By.id("enrollUserOptionsDiv")).isSelected();
if(btnSelected = true){
if(odriver.findElement(By.xpath("//input[@value=\"No\"]")).isSelected())
{
System.out.println( odriver.findElement(By.xpath("//input[@value=\"No\"]")).isSelected());
odriver.findElement(By.xpath("//input[@value=\"Yes\"]")).click();} //fails at this line