Trigger/run earlier interaction in Selenium WebDriver










0















I want to achieve the following process. The scripts are written in Katalon, but it does not matter. Selenium approach is enough.



I test an appearance of two elements in a dialog window. If a text message appears, the second element will not come and the dialog window is closed. If the first element (message) is not displayed, a button that displays after a certain amount of time is clicked.



I would like to continue and avoid using wait until element is visible/invisible. I do not know how to do it, but any action is triggered first it will go through it.



The problem is that the test waits for the message for the certain time and if it not displayed in (let say 30 sec), it clicks on the button. I want to avoid to wait until it is visible, and instead of waiting just to click immediately on the button. So the aim is to track two parallel actions (not selenium actions) and which one is fired first. Is there any approach? Maybe using tasks?



Here is the code:



TestObject dialogWinEl = findTestObject("Object Repository/FinacDocAndPayments/dialogWindow/div_dialogWin")
WebUI.waitForElementVisible(dialogWinEl, GlobalVariable.TIMEOUT_ELEMENT, FailureHandling.OPTIONAL)

TestObject statusMsgFilesDownloadEl = findTestObject("Object Repository/InvoiceDetailPage/div_dialogWin/span_noDocFoundStatus")
boolean noDownloadFiles = WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL)

if(noDownloadFiles)
KeywordUtil.markPassed("No files found to download. Closing dialog")

else
KeywordUtil.markPassed("Files found. Click on Download files")
TestObject btnEl = findTestObject('Object Repository/InvoicesAndPayments_Global/btn_generic', [('btn_text'):btnName])
WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(btnEl)
KeywordUtil.markPassed("File downloaded. Closing dialog window")


TestObject xBtn = findTestObject('Object Repository/InvoicesAndPayments_Global/confDialog/div_closeBtn')
WebUI.waitForElementClickable(xBtn, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(xBtn)
KeywordUtil.markPassed("Dialog window has been closed")


Basically the variable noDownloadFiles is equal to the status of the particular element (visible or not) and it waits for the time that is in the var GlobalVariable.DOWNLOAD_BTN = 20sec. The problem here is if this variable is false it means that it waited for the specific amount of time and then it continues in the else branch. The point is if the button appears earlier it does not have to wait to see if statusMsgFilesDownloadEl is visible or not.
I simply want to use this:



WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL) 


and



WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT) 


and once the first or second is evaluated it continues. There is no reason to wait for one and then for the other.










share|improve this question
























  • We don't even know your current approach... post your code and describe what you are attempting to do with the current approach. Then explain what problems you are running into with error messages, etc.

    – JeffC
    Nov 14 '18 at 19:20











  • @JeffC Ok added

    – Michal
    Nov 14 '18 at 19:46











  • It is not clear what are you trying to achieve. Is it even possible to click the btnEl before the statusMsgFilesDownloadEl appears?

    – Mate Mrše
    Dec 14 '18 at 9:19















0















I want to achieve the following process. The scripts are written in Katalon, but it does not matter. Selenium approach is enough.



I test an appearance of two elements in a dialog window. If a text message appears, the second element will not come and the dialog window is closed. If the first element (message) is not displayed, a button that displays after a certain amount of time is clicked.



I would like to continue and avoid using wait until element is visible/invisible. I do not know how to do it, but any action is triggered first it will go through it.



The problem is that the test waits for the message for the certain time and if it not displayed in (let say 30 sec), it clicks on the button. I want to avoid to wait until it is visible, and instead of waiting just to click immediately on the button. So the aim is to track two parallel actions (not selenium actions) and which one is fired first. Is there any approach? Maybe using tasks?



Here is the code:



TestObject dialogWinEl = findTestObject("Object Repository/FinacDocAndPayments/dialogWindow/div_dialogWin")
WebUI.waitForElementVisible(dialogWinEl, GlobalVariable.TIMEOUT_ELEMENT, FailureHandling.OPTIONAL)

TestObject statusMsgFilesDownloadEl = findTestObject("Object Repository/InvoiceDetailPage/div_dialogWin/span_noDocFoundStatus")
boolean noDownloadFiles = WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL)

if(noDownloadFiles)
KeywordUtil.markPassed("No files found to download. Closing dialog")

else
KeywordUtil.markPassed("Files found. Click on Download files")
TestObject btnEl = findTestObject('Object Repository/InvoicesAndPayments_Global/btn_generic', [('btn_text'):btnName])
WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(btnEl)
KeywordUtil.markPassed("File downloaded. Closing dialog window")


TestObject xBtn = findTestObject('Object Repository/InvoicesAndPayments_Global/confDialog/div_closeBtn')
WebUI.waitForElementClickable(xBtn, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(xBtn)
KeywordUtil.markPassed("Dialog window has been closed")


Basically the variable noDownloadFiles is equal to the status of the particular element (visible or not) and it waits for the time that is in the var GlobalVariable.DOWNLOAD_BTN = 20sec. The problem here is if this variable is false it means that it waited for the specific amount of time and then it continues in the else branch. The point is if the button appears earlier it does not have to wait to see if statusMsgFilesDownloadEl is visible or not.
I simply want to use this:



WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL) 


and



WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT) 


and once the first or second is evaluated it continues. There is no reason to wait for one and then for the other.










share|improve this question
























  • We don't even know your current approach... post your code and describe what you are attempting to do with the current approach. Then explain what problems you are running into with error messages, etc.

    – JeffC
    Nov 14 '18 at 19:20











  • @JeffC Ok added

    – Michal
    Nov 14 '18 at 19:46











  • It is not clear what are you trying to achieve. Is it even possible to click the btnEl before the statusMsgFilesDownloadEl appears?

    – Mate Mrše
    Dec 14 '18 at 9:19













0












0








0








I want to achieve the following process. The scripts are written in Katalon, but it does not matter. Selenium approach is enough.



I test an appearance of two elements in a dialog window. If a text message appears, the second element will not come and the dialog window is closed. If the first element (message) is not displayed, a button that displays after a certain amount of time is clicked.



I would like to continue and avoid using wait until element is visible/invisible. I do not know how to do it, but any action is triggered first it will go through it.



The problem is that the test waits for the message for the certain time and if it not displayed in (let say 30 sec), it clicks on the button. I want to avoid to wait until it is visible, and instead of waiting just to click immediately on the button. So the aim is to track two parallel actions (not selenium actions) and which one is fired first. Is there any approach? Maybe using tasks?



Here is the code:



TestObject dialogWinEl = findTestObject("Object Repository/FinacDocAndPayments/dialogWindow/div_dialogWin")
WebUI.waitForElementVisible(dialogWinEl, GlobalVariable.TIMEOUT_ELEMENT, FailureHandling.OPTIONAL)

TestObject statusMsgFilesDownloadEl = findTestObject("Object Repository/InvoiceDetailPage/div_dialogWin/span_noDocFoundStatus")
boolean noDownloadFiles = WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL)

if(noDownloadFiles)
KeywordUtil.markPassed("No files found to download. Closing dialog")

else
KeywordUtil.markPassed("Files found. Click on Download files")
TestObject btnEl = findTestObject('Object Repository/InvoicesAndPayments_Global/btn_generic', [('btn_text'):btnName])
WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(btnEl)
KeywordUtil.markPassed("File downloaded. Closing dialog window")


TestObject xBtn = findTestObject('Object Repository/InvoicesAndPayments_Global/confDialog/div_closeBtn')
WebUI.waitForElementClickable(xBtn, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(xBtn)
KeywordUtil.markPassed("Dialog window has been closed")


Basically the variable noDownloadFiles is equal to the status of the particular element (visible or not) and it waits for the time that is in the var GlobalVariable.DOWNLOAD_BTN = 20sec. The problem here is if this variable is false it means that it waited for the specific amount of time and then it continues in the else branch. The point is if the button appears earlier it does not have to wait to see if statusMsgFilesDownloadEl is visible or not.
I simply want to use this:



WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL) 


and



WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT) 


and once the first or second is evaluated it continues. There is no reason to wait for one and then for the other.










share|improve this question
















I want to achieve the following process. The scripts are written in Katalon, but it does not matter. Selenium approach is enough.



I test an appearance of two elements in a dialog window. If a text message appears, the second element will not come and the dialog window is closed. If the first element (message) is not displayed, a button that displays after a certain amount of time is clicked.



I would like to continue and avoid using wait until element is visible/invisible. I do not know how to do it, but any action is triggered first it will go through it.



The problem is that the test waits for the message for the certain time and if it not displayed in (let say 30 sec), it clicks on the button. I want to avoid to wait until it is visible, and instead of waiting just to click immediately on the button. So the aim is to track two parallel actions (not selenium actions) and which one is fired first. Is there any approach? Maybe using tasks?



Here is the code:



TestObject dialogWinEl = findTestObject("Object Repository/FinacDocAndPayments/dialogWindow/div_dialogWin")
WebUI.waitForElementVisible(dialogWinEl, GlobalVariable.TIMEOUT_ELEMENT, FailureHandling.OPTIONAL)

TestObject statusMsgFilesDownloadEl = findTestObject("Object Repository/InvoiceDetailPage/div_dialogWin/span_noDocFoundStatus")
boolean noDownloadFiles = WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL)

if(noDownloadFiles)
KeywordUtil.markPassed("No files found to download. Closing dialog")

else
KeywordUtil.markPassed("Files found. Click on Download files")
TestObject btnEl = findTestObject('Object Repository/InvoicesAndPayments_Global/btn_generic', [('btn_text'):btnName])
WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(btnEl)
KeywordUtil.markPassed("File downloaded. Closing dialog window")


TestObject xBtn = findTestObject('Object Repository/InvoicesAndPayments_Global/confDialog/div_closeBtn')
WebUI.waitForElementClickable(xBtn, GlobalVariable.TIMEOUT_ELEMENT)
WebUI.click(xBtn)
KeywordUtil.markPassed("Dialog window has been closed")


Basically the variable noDownloadFiles is equal to the status of the particular element (visible or not) and it waits for the time that is in the var GlobalVariable.DOWNLOAD_BTN = 20sec. The problem here is if this variable is false it means that it waited for the specific amount of time and then it continues in the else branch. The point is if the button appears earlier it does not have to wait to see if statusMsgFilesDownloadEl is visible or not.
I simply want to use this:



WebUI.waitForElementVisible(statusMsgFilesDownloadEl, GlobalVariable.DOWNLOAD_BTN, FailureHandling.OPTIONAL) 


and



WebUI.waitForElementClickable(btnEl, GlobalVariable.TIMEOUT_ELEMENT) 


and once the first or second is evaluated it continues. There is no reason to wait for one and then for the other.







selenium-webdriver task katalon-studio






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 14 '18 at 13:04









Mate Mrše

1,8642627




1,8642627










asked Nov 14 '18 at 16:55









MichalMichal

18613




18613












  • We don't even know your current approach... post your code and describe what you are attempting to do with the current approach. Then explain what problems you are running into with error messages, etc.

    – JeffC
    Nov 14 '18 at 19:20











  • @JeffC Ok added

    – Michal
    Nov 14 '18 at 19:46











  • It is not clear what are you trying to achieve. Is it even possible to click the btnEl before the statusMsgFilesDownloadEl appears?

    – Mate Mrše
    Dec 14 '18 at 9:19

















  • We don't even know your current approach... post your code and describe what you are attempting to do with the current approach. Then explain what problems you are running into with error messages, etc.

    – JeffC
    Nov 14 '18 at 19:20











  • @JeffC Ok added

    – Michal
    Nov 14 '18 at 19:46











  • It is not clear what are you trying to achieve. Is it even possible to click the btnEl before the statusMsgFilesDownloadEl appears?

    – Mate Mrše
    Dec 14 '18 at 9:19
















We don't even know your current approach... post your code and describe what you are attempting to do with the current approach. Then explain what problems you are running into with error messages, etc.

– JeffC
Nov 14 '18 at 19:20





We don't even know your current approach... post your code and describe what you are attempting to do with the current approach. Then explain what problems you are running into with error messages, etc.

– JeffC
Nov 14 '18 at 19:20













@JeffC Ok added

– Michal
Nov 14 '18 at 19:46





@JeffC Ok added

– Michal
Nov 14 '18 at 19:46













It is not clear what are you trying to achieve. Is it even possible to click the btnEl before the statusMsgFilesDownloadEl appears?

– Mate Mrše
Dec 14 '18 at 9:19





It is not clear what are you trying to achieve. Is it even possible to click the btnEl before the statusMsgFilesDownloadEl appears?

– Mate Mrše
Dec 14 '18 at 9:19












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305207%2ftrigger-run-earlier-interaction-in-selenium-webdriver%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305207%2ftrigger-run-earlier-interaction-in-selenium-webdriver%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus