标签: selected

如何使用Selenium WebDriver和Python获取选定的选项?

如何使用Selenium WebDriver和Python获取所选选项:

有人有解决方案getFirstSelectedOption吗?

我用它来获取select元素:

try:
    FCSelect = driver.find_element_by_id('FCenter')
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: F Center Select found"
except NoSuchElementException:
    self.TestEventLog = self.TestEventLog + "<br>Error: Select FCenter element not found"
Run Code Online (Sandbox Code Playgroud)

是否存在类似于或类似于'getFirstSelectedOption'的内容,如下所示:

try:
    FCenterSelectedOption = FCenterSelect.getFirstSelectedOption()
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: F Center Selected (First) found"
except NoSuchElementException:
    self.TestEventLog = self.TestEventLog + "<br>Error: Selected Option element not found"
Run Code Online (Sandbox Code Playgroud)

然后我想用以下内容验证内容getText:

try:
    FCenterSelectedOptionText = FCenterSelectedOption.getText()
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: FCenter Selected Option Text …
Run Code Online (Sandbox Code Playgroud)

python selenium selecteditem selected selenium-webdriver

12
推荐指数
1
解决办法
2万
查看次数

如何使用jQuery查找具有特定值的选项标记

我正在尝试使用选定的特定值设置一个选项(使用jQuery).我有一个字符串:

var data = '<select><option value="1">A</option><option value="2">B</option><option value="3">C</option></select>';
Run Code Online (Sandbox Code Playgroud)

现在我正在尝试找到值为2的选项标签并将其设置为选中

$(data).find('option[value=2]').attr('selected','selected');
Run Code Online (Sandbox Code Playgroud)

这不起作用:-( ...我也尝试过:

$(data).find('option').each(function(){
if($(this).val()==2){
    $(this).attr('selected','selected');
}
});
Run Code Online (Sandbox Code Playgroud)

也没有工作...那里有谁可以提供帮助吗?

jquery find selected option

10
推荐指数
1
解决办法
3万
查看次数

如何检查"Radiobutton"是否被检查?

我想建立一个条件结构(if-else) RadioButton

我希望在选择Radiobutton RB1时,此功能处于活动状态:

regAuxiliar = ultimoRegistro;
Run Code Online (Sandbox Code Playgroud)

当选择单选按钮RB2时,此功能有效:

regAuxiliar = objRegistro;
Run Code Online (Sandbox Code Playgroud)

抱歉我的英语,我是巴西人.

java android selected radio-button checked

10
推荐指数
5
解决办法
16万
查看次数

html选择选项SELECTED

我有我的PHP

$sel = "
    <option> one </option>
    <option> two </option>
    <option> thre </option>
    <option> four </option>
";
Run Code Online (Sandbox Code Playgroud)

假设我有一个内联URL = site.php?sel=one

如果我没有在变量中保存这些选项,我可以这样做,使其中一个选项为SELECTED,其中value等于 $_GET[sel]

<option <?php if($_GET[sel] == 'one') echo"selected"; ?> > one </option>
<option <?php if($_GET[sel] == 'two') echo"selected"; ?> > two </option>
<option <?php if($_GET[sel] == 'three') echo"selected"; ?> > three </option>
<option <?php if($_GET[sel] == 'four') echo"selected"; ?> > four </option>
Run Code Online (Sandbox Code Playgroud)

但问题是,我需要将这些选项保存在变量中,因为我有很多选项,我需要多次调用该变量.

有没有办法让选项在哪里选择value = $_GET[sel]

html php selected option

10
推荐指数
3
解决办法
13万
查看次数

JTable:如何获取选定的单元格?

我有一个JTable及其TableModel,它运行良好,但我现在要做的是获取它的选定单元格.我想过做的事情:

int rows = this.getTable().getRowCount();
int columns = this.getTable().getColumnCount();
for(int i = 0 ; i < rows ; i++)
{
    for(int j = 0 ; j < columns ; j++)
    {
         if(table.getCell(i,j).isSelected() //...
    }
}
Run Code Online (Sandbox Code Playgroud)

但当然这样的事情不存在.我该怎么做呢?

swing jtable cell selected

9
推荐指数
2
解决办法
5万
查看次数

Symfony2 - 为实体字段设置选定的值

我正在尝试在实体字段中设置选定的值.按照很多讨论,我看到关于这个话题,我想设置的data选项,但这不选择任何默认值:

class EventType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('place', 'entity', array(
                'class' => 'RoyalMovePhotoBundle:Place',
                'property' => 'name',
                'empty_value' => "Choisissez un club",
                'mapped' => false,
                'property_path' => false,
                'data' => 2
            ))
            ->add('begin')
            ->add('end')
            ->add('title')
            ->add('description')
        ;
    }

    // ...
}
Run Code Online (Sandbox Code Playgroud)

通过寻找更多,我发现有些人不得不停用映射到实体的表单.这似乎合乎逻辑,所以我试图添加'mapped' => false选项,但没有成功......

如果它可以帮助,这是我的控制器:

class EventController extends Controller
{
    // ...

    public function addAction()
    {
        $request = $this->getRequest();
        $em = $this->getDoctrine()->getManager();

        $event = new Event();
        $form = $this->createForm(new EventType(), …
Run Code Online (Sandbox Code Playgroud)

forms entity selected symfony

9
推荐指数
2
解决办法
3万
查看次数

刷新后从动态下拉列表中维护选择值

我有一个由11个元素组成的表单(输入选择标签).表单具有表单验证,当用户输入不正确的数据时,该表单验证会在字段旁边提示错误消息.我希望在刷新页面后保持输入到字段中的正确数据.

例如,假设正确填充的10个字段和1个字段不正确.当用户按下提交按钮时,字段附近会显示错误消息.我想要做的是保持选择10个正确的值,这样用户就不必重新开始了.

对于输入元素,这工作正常,但对于选择元素,这是行不通的. 重要的是我使用PHP动态填充下拉列表.

这可能在PHP中做,因为我无法弄清楚如何?

下面是我如何生成select元素的下拉列表的示例.

    select name="location">
  <?php
     include("../includes/db_connect.php"); 
     $sql_loc = "SELECT description FROM location ORDER BY description ASC";
     $result_loc = mysqli_query($connection, $sql_loc);

     if(mysqli_num_rows($result_loc) > 0){
       while($row = mysqli_fetch_assoc($result_loc)){
       echo '<option value="' . htmlspecialchars($row['description']) . '">' 
       . htmlspecialchars($row['description']) 
       . '</option>';
     }
    }                                             

      ?> 
    </select>
Run Code Online (Sandbox Code Playgroud)

至于输入元素,我使用以下内容实现此目的:

<input type="text" name="serial" value="<?php echo $serial;?>">
Run Code Online (Sandbox Code Playgroud)

html php html5 netbeans selected

9
推荐指数
1
解决办法
1865
查看次数

WPF ListBox图像选择了传奇继续

好吧,在我的ListBox滚动图像w /文本等等saga继续.当我单击其中一个项目以选择它时,它会运行一个过程来打开Web浏览器并转到特定的URL.我现在遇到的问题是,当WPF应用程序失去焦点,并且Web浏览器打开时,在列表框内单击的项目将变为白色.这是整个ListBox XAML.我已将所选项目设置为透明,这是否与WPF应用程序失去焦点有关?

有什么我可以添加运行该过程的代码来打开Web浏览器以将焦点设置回WPF应用程序?

谢谢.

   <ListBox ItemsSource="{Binding Source={StaticResource WPFApparelCollection}}" Margin="61,-8,68,-18" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" SelectionMode="Single" x:Name="list1" MouseLeave="List1_MouseLeave" MouseMove="List1_MouseMove" Style="{DynamicResource ListBoxStyle1}" Background="Transparent" BorderThickness="0">
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
                <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
                <Setter Property="Padding" Value="20,10,20,10" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Border x:Name="Bd" SnapsToDevicePixels="true" Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="true">
                                    <Setter Property="Background" TargetName="Bd" …
Run Code Online (Sandbox Code Playgroud)

wpf listbox focus image selected

8
推荐指数
1
解决办法
8335
查看次数

如何以编程方式在活动中选择RadioButton

在我的项目中,我从数据库中获得性别的值为0和1.
0表示男性,1表示女性.
根据这个值,我需要检查RadioGroup中相应的RadioButton.
如果按0,将检查radio0或检查radio1.
我不知道如何根据这个字符串值检查单选按钮...
这是我试过的代码:

      String gendd=ViewProfileActivity.participantview.get(4);
      System.out.println("Gender:::::"+gendd);

      male=(RadioButton)findViewById(R.id.radio0);
       female=(RadioButton)findViewById(R.id.radio1);
       if(gendd.equals("0")){

           male.setSelected(true);
           female.setSelected(false);
       }
       else
           {
           male.setSelected(false);

           female.setSelected(true);

           }
Run Code Online (Sandbox Code Playgroud)

但它失败了.谁能帮我?

android button selected radio

8
推荐指数
2
解决办法
2万
查看次数

在Flutter中选择下拉项时出错

我对Flutter下拉菜单有疑问。当我选择其中一项时,会引发错误:

引发了另一个异常:'package:flutter / src / material / dropdown.dart':断言失败:481行pos 15:'value == null || items.where(((DropdownMenuItem item)=> item.value == value).length == 1':不正确。

我正在搜索,人们告诉您,产生此错误是因为所选元素不属于原始列表,但是经过一些调试后,我看到了。我找不到此错误的根源,因此不胜感激。

这是我的代码

FeedCategory模型

import 'package:meta/meta.dart';

class FeedCategory {
  static final dbId = "id";
  static final dbName = "name";

  int id;
  String name;

  FeedCategory({this.id, @required this.name});

  FeedCategory.fromMap(Map<String, dynamic> map)
      : this(
    id: map[dbId],
    name: map[dbName],
  );

  Map<String, dynamic> toMap() {
    return {
      dbId: id,
      dbName: name,
    };
  }

  @override
  String toString() {
    return 'FeedCategory{id: $id, name: $name}';
  }
}
Run Code Online (Sandbox Code Playgroud)

小部件

import 'package:app2date/repository/repository.dart'; …
Run Code Online (Sandbox Code Playgroud)

selected dropdown flutter

8
推荐指数
2
解决办法
2848
查看次数