How to wait untill drop down values load in if else condition in robot framework

让人想犯罪 __ 提交于 2020-06-16 17:32:28

问题


My scenarios are: I have two drop down values side by side if the first drop down-selected based on the value selected second drop-down values will be loaded from that we need to pick one value. in one case from the first drop down if I select unknown or any legal purpose I should not go for the second dropdown. this is what the requirement I have please help me out. Below is the code I have written

Variables

${var1}=    Unknown
${var2}=    Any legal purpose

The user selects random NAICS code and subcode from the drop-down

${selectedNAICScode}= User selects NAICS code from the drop down       
${NAICS_code}  run keyword if    
${selectedNAICScode}!=${var1} or ${selectedNAICScode}!=${var2} run keywords
        ...    element should be visible        xpath://select[@id="ddlNAICSSubCode"]

#     ...    is visible          ${NAICS_subcode}
...    User selects NAICS-sub code from the drop down
...    ELSE     run keywords
...    element should not be visible        xpath://select[@id='ddlNAICSSubCode']

Even though we are giving one argument when I run the script it is saying expecting 1 to 2 arguments but got 0. my question is how we can wait until the drop-down values load into the drop-down in else condition.


回答1:


You can use the following functionality:

WebDriverWait wait = new WebDriverWait(driver, INSERT_INTEGER_WAITING_TIME);

boolean waitUntil = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("ENTER_YOUR_XPATH_OR_OTHER_ATTRIBUTE")));

In this way, your action will happen only when the element is going to be visible.

If you need further information check this link



来源:https://stackoverflow.com/questions/61569419/how-to-wait-untill-drop-down-values-load-in-if-else-condition-in-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!