Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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
Selenium未正确解释属性值_Selenium - Fatal编程技术网

Selenium未正确解释属性值

Selenium未正确解释属性值,selenium,Selenium,如果条件在Selenium中无法正常工作,则返回My属性值。它正在向控制台打印字符串值true,但以下假设打印SMS号码的条件复选框被禁用。打印其他输出 String value=customerSectionSMSNumber.getAttribute("readonly"); System.out.println("Value = "+ value); if ( value == "true") { System.out.printl

如果条件在Selenium中无法正常工作,则返回My属性值。它正在向控制台打印字符串值true,但以下假设打印SMS号码的条件复选框被禁用。打印其他输出

String value=customerSectionSMSNumber.getAttribute("readonly");
        System.out.println("Value = "+ value);

        if ( value == "true") {
            System.out.println("SMS number checkbox is disabled");
        }`  else {
            System.out.println(customerSectionSMSNumber.getAttribute("readonly"));
        }
试试这个代码

String value=customerSectionSMSNumber.getAttribute("readonly");
        System.out.println("Value = "+ value);
   if(value!=null){
        if ( value.contains("true")) {
            System.out.println("SMS number checkbox is disabled");
          }`  else {
            System.out.println(customerSectionSMSNumber.getAttribute("readonly"));
         }
   }

不能将字符串值与等于运算符进行比较。您必须使用下面给出的字符串类的
equals
contains
方法

    String value=customerSectionSMSNumber.getAttribute("readonly");
    System.out.println("Value = "+ value);

    if ( value.equals("true")) {
        System.out.println("SMS number checkbox is disabled");
    }`  else {
        System.out.println(customerSectionSMSNumber.getAttribute("readonly"));
    }
String value=customerSectionSMSNumber.getAttribute("readonly");
        System.out.println("Value = "+ value);

        if ( Boolean.parseBoolean(value)) {
            System.out.println("SMS number checkbox is disabled");
        }`  else {
            System.out.println(customerSectionSMSNumber.getAttribute("readonly"));
        }
否则,将字符串值转换为布尔值,并使用下面给出的if子句

    String value=customerSectionSMSNumber.getAttribute("readonly");
    System.out.println("Value = "+ value);

    if ( value.equals("true")) {
        System.out.println("SMS number checkbox is disabled");
    }`  else {
        System.out.println(customerSectionSMSNumber.getAttribute("readonly"));
    }
String value=customerSectionSMSNumber.getAttribute("readonly");
        System.out.println("Value = "+ value);

        if ( Boolean.parseBoolean(value)) {
            System.out.println("SMS number checkbox is disabled");
        }`  else {
            System.out.println(customerSectionSMSNumber.getAttribute("readonly"));
        }