如何在Robot FrameWork中清空检查列表

时间:2017-06-09 14:45:16

标签: robotframework

Keyword2

Empty正在返回数据列表。我想检查它是否正在返回public static Bitmap viewToBitmap(Activity activity, Bitmap bitmap, String mapURL, String latLong, String dateTime) { try { AsyncTask asyncTask = new BackgroundUtils.setImageFromUrl().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mapURL); Bitmap googleBitmap = (Bitmap) asyncTask.get(); Bitmap.Config bitmapConfig = bitmap.getConfig(); if (bitmapConfig == null) { bitmapConfig = Bitmap.Config.ARGB_8888; } Bitmap bmp = bitmap.copy(bitmapConfig, true); Canvas canvas = new Canvas(bmp); LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup root = (ViewGroup) activity.findViewById(R.id.relativeLayout); View layout = inflater.inflate(R.layout.screenshot_content, root, false); ImageView cameraView = (ImageView) layout.findViewById(R.id.cameraView); ImageView mapView = (ImageView) layout.findViewById(R.id.mapView); TextView latLongView = (TextView) layout.findViewById(R.id.latLongView); TextView dateTimeView = (TextView) layout.findViewById(R.id.dateTimeView); cameraView.setImageBitmap(bitmap); mapView.setImageBitmap(googleBitmap); latLongView.setText(latLong); dateTimeView.setText(dateTime); layout.setDrawingCacheEnabled(true); layout.measure(View.MeasureSpec.makeMeasureSpec(canvas.getWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(canvas.getHeight(), View.MeasureSpec.EXACTLY)); layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight()); layout.draw(canvas); return bmp; } catch (Exception e) { e.printStackTrace(); } return null; } 列表。请帮帮我吗?

3 个答案:

答案 0 :(得分:4)

BuiltIn库包含关键字Should be emptyShould not be empty,可用于验证列表的长度。

Should be empty      ${columnlist}

Should not be empty  ${columnlist}

答案 1 :(得分:0)

以防万一有人来这里寻找答案,该答案也可以解决:

  

如果$ {columnlist}不为空,则必须在其下方执行关键字。是否可以使用If语句? – Orsu Suni 17年6月12日在4:44

以下任何一个选项都应该有所帮助(注意:仅在RIDE中使用,我想它们也将对其他人有用):

  1. $ {len}获取长度$ {columnlist} ----如果列表为空,将返回零,然后您可以在条件中使用$ {len}。
  2. '@ {columnlist}'=='@ {EMPTY}'----如果list为空,则应该返回true,尽管到目前为止我只将其与RUN KEYIF IF一起使用。

答案 2 :(得分:0)

在我看来,Robot中的陈述/条件有些令人困惑。先前的建议2.对我不起作用。我正在使用:Robot Framework 3.1.2(win32上的Python 3.4.1)

我获得了预期的解决方案:

*** Test Cases ***
TC1
    ${marker_files}  Create List  dummy3  dummy4  dummy5
    Run keyword unless  ${marker_files} == @{EMPTY}  Operation on list 
    marker_files=${marker_files}

tc2
    ${marker_files}  Create List  @{EMPTY}
    Run keyword unless  ${marker_files} == @{EMPTY}  Operation on list  
    marker_files=${marker_files}

*** Keywords ***
Operation on list
    [Arguments]  ${marker_files}=def
    log to console  \ndo something on list