Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/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
Java 列表大小仅在调试模式下捕获_Java_Selenium_Debugging_Automation_Ui Automation - Fatal编程技术网

Java 列表大小仅在调试模式下捕获

Java 列表大小仅在调试模式下捕获,java,selenium,debugging,automation,ui-automation,Java,Selenium,Debugging,Automation,Ui Automation,以粗体突出显示,即Totalist捕获值0。但当我在调试模式下运行时,会捕获正确的值。serviceX在所有下拉列表中都很常见,因此我将所有FindElement分配到一个列表中,然后从excel中选择一个与该值匹配的值 private By serviceX=By.xpath(//div/ul/li[@class='datixSelectOption'或@class='datixSelectOption-datixSelectOption-hover']) public void create

以粗体突出显示,即Totalist捕获值0。但当我在调试模式下运行时,会捕获正确的值。serviceX在所有下拉列表中都很常见,因此我将所有FindElement分配到一个列表中,然后从excel中选择一个与该值匹配的值

private By serviceX=By.xpath(//div/ul/li[@class='datixSelectOption'或@class='datixSelectOption-datixSelectOption-hover'])

public void createIncident(映射数据映射)引发InterruptedException {

//从下拉列表中选择谁或什么的块
String val1=(String)dataMap.get(“WhoorWhat”);
isElementPresent(whoOrWhat)。单击();
@抑制警告(“未选中”)
List listElements=getWebElements(serviceX);
int totalist=liselements.size();
**System.out.println(totallist)**
for(WebElement li:liselements)
{
System.out.println(li.getText());
如果(li.getText().equals(val1)){
li.click();
打破
}
}
liselements.clear();
//块来选择特定的服务
if(isElementPresent(specificService).isDisplayed())
{
stringservice=(String)dataMap.get(“SpecificService”);
字符串[]serviceArr=service.split(“-”);
System.out.println(serviceArr[0]);
System.out.println(serviceArr[1]);
getSpecificService().sendKeys(serviceArr[0]);
@抑制警告(“未选中”)
List serviceList=getWebElements(serviceX);
int totalServiceList=serviceList.size();
System.out.println(totalServiceList);

对于(int j=0;控制台上totallist=0的jOutput和引发的异常-org.openqa.selenium.TimeoutException:预期条件失败:等待by.id:service\u id\u title定位的元素的可见性(尝试20秒,间隔500毫秒).Execution control正在移动到特定于webelement的服务。通常,如果WebDriver仅在调试模式下捕获某些内容,则意味着该元素没有足够的时间以正常模式显示在UI上,但在调试模式下需要更多的时间,或者您只是点击了断点,从而为UI更新/绘制元素提供了额外的时间。Outputotallist=0的控制台上的t和引发的异常-org.openqa.selenium.TimeoutException:预期条件失败:等待by.id:service\u id\u title定位的元素的可见性(尝试20秒,间隔500毫秒).Execution control正在移动到特定于webelement的服务。通常,如果WebDriver仅在调试模式下捕获某些内容,则意味着该元素没有足够的时间以正常模式显示在UI上,但在调试模式下需要更多的时间,或者您只是点击了断点,从而为UI更新/绘制元素提供了额外的时间。
    //Block to select Who or what from drop down
    String val1 =(String) dataMap.get("WhoorWhat");
    isElementPresent(whoOrWhat).click();
     @SuppressWarnings("unchecked")
     List<WebElement> listElements=getWebElements(serviceX);
     int totallist =  listElements.size();
        **System.out.println(totallist);**
     for (WebElement li : listElements) 
     {
        System.out.println(li.getText());
        
         if (li.getText().equals(val1)) { 
             li.click(); 
             break;
             }
        
        
    }
     listElements.clear();
    
    //Block to select specific service
    if(isElementPresent(specificService).isDisplayed()) 
    {
        String service  = (String) dataMap.get("SpecificService"); 
        String [] serviceArr =  service.split("-");
        System.out.println(serviceArr[0]);
        System.out.println(serviceArr[1]);
        getSpecificService().sendKeys(serviceArr[0]);
    
        @SuppressWarnings("unchecked")
        List<WebElement> serviceList = getWebElements(serviceX);
        int totalServiceList =  serviceList.size();
        System.out.println(totalServiceList);
        for (int j = 0;j<=totalServiceList; j++) {
             String serviceName = serviceList.get(j).getText();
             System.out.println(serviceName);
            
 
             if(serviceName.contains(serviceArr[1])) {
            System.out.println(serviceName);
            serviceList.get(j).click();
            break;
        }
        }
        serviceList.clear();
    }
            
          
    //Block to select Where did this incident occur? from drop down 
        getIncidentOccur().click();
        @SuppressWarnings("unchecked")
        List<WebElement> incidentOccur=getWebElements(serviceX);

        String occurPlace =(String) dataMap.get("IncidentOccur");
        System.out.println(occurPlace);
        for (WebElement li1 : incidentOccur) {
            System.out.println(li1.getText());
            
             if (li1.getText().equals(occurPlace)) { 
                 li1.click(); 
                 break;
                 }
            
            
        }
        incidentOccur.clear();
        
    //Block to select location from text dropdown

        String loc =  (String) dataMap.get("Location"); 
        String [] locationArr =  loc.split("-");
        getLocationField().sendKeys(locationArr[1]);
    
        @SuppressWarnings("unchecked")
        List<WebElement> listLocations = getWebElements(serviceX);
        int totalList =  listLocations.size();
        //System.out.println(totalList);
        for (int j = 0;j<=totalList; j++) {
             String locationName = listLocations.get(j).getText();
             //System.out.println(locationName);
            
 
             if(locationName.contains(locationArr[0])) {
             //System.out.println(locationName);
                 listLocations.get(j).click();
                 break;
        }
        }
        listLocations.clear();

        
        //Block to select Principal incident type
        String principalIncident  = (String) dataMap.get("PrincipalIncident"); 
        getPrincipalIncidentType().sendKeys(principalIncident);
    
        @SuppressWarnings("unchecked")
        List<WebElement> principalList = getWebElements(serviceX);
        int totalPrincipalList =  principalList.size();
        for (int j = 0;j<=totalPrincipalList; j++) {
             String principalName = principalList.get(j).getText();
             System.out.println(principalName);
            
 
             if(principalName.contains(principalIncident)) {
                 principalList.get(j).click();
            break;
        }
        }
        principalList.clear();    
    }
}