Selenium - clicking button registered but not redirecting page to target link
up vote
1
down vote
favorite
I'm testing a web UI using Selenium in Java. I've come to a test case where a button which links to another page is supposed to be clicked right after loading a new page.
However, sometimes when the button is clicked, no page redirect is triggered. I'm sure that the button gets clicked correctly, as the button animation triggers and selenium proceeds the test, where it fails because it doesn't find any elements that are supposed to be on the next page.
One possible workaround would be a Thread.sleep() before clicking the button, but I'd like to avoid this solution.
I've tried this workaround where I check if redirect happened, but this just causes the page to loop and never actually load.
while(!driver.getCurrentUrl().toLowerCase().endsWith("login/checkout")) {
driver.findElement(By.cssSelector("button[data-checkout-url='/cart/checkout']")).click();
}
The button in question is this one, for example. However, this behaviour happens on multiple buttons.
<button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button"
data-checkout-url="/cart/checkout">
Checkout
</button>
The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system. The button normally only redirects you to login page.
java selenium testing automation
add a comment |
up vote
1
down vote
favorite
I'm testing a web UI using Selenium in Java. I've come to a test case where a button which links to another page is supposed to be clicked right after loading a new page.
However, sometimes when the button is clicked, no page redirect is triggered. I'm sure that the button gets clicked correctly, as the button animation triggers and selenium proceeds the test, where it fails because it doesn't find any elements that are supposed to be on the next page.
One possible workaround would be a Thread.sleep() before clicking the button, but I'd like to avoid this solution.
I've tried this workaround where I check if redirect happened, but this just causes the page to loop and never actually load.
while(!driver.getCurrentUrl().toLowerCase().endsWith("login/checkout")) {
driver.findElement(By.cssSelector("button[data-checkout-url='/cart/checkout']")).click();
}
The button in question is this one, for example. However, this behaviour happens on multiple buttons.
<button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button"
data-checkout-url="/cart/checkout">
Checkout
</button>
The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system. The button normally only redirects you to login page.
java selenium testing automation
What is there behind the button? Does it perform an HTML form submit? Does it run JavaScript? Please share the relevant HTML code.
– sleske
Nov 7 at 9:35
The exact button is following: <button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button" data-checkout-url="/cart/checkout">Checkout</button>
– fugasjunior
Nov 7 at 9:52
Thanks. In general, please edit your question if you have additional details (comments are easily overlooked and may be deleted).
– sleske
Nov 7 at 10:23
As to the button: We need more information, as I indicated in my question. Is there JavaScript attached to the button? The classes associated ("js-continue-checkout-button") seem to indicate this. Or does it just cause a standard form submit?
– sleske
Nov 7 at 10:28
Thanks for the advice, I'll edit the question. The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system and can't show you the javascript code itself. The button normally only redirects you to login page. I am just looking for a reasonable solution to ensure this button is clicked correctly and redirect happens, but I understand that it might not be possible without the knowledge of underlying javascript.
– fugasjunior
Nov 7 at 11:06
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm testing a web UI using Selenium in Java. I've come to a test case where a button which links to another page is supposed to be clicked right after loading a new page.
However, sometimes when the button is clicked, no page redirect is triggered. I'm sure that the button gets clicked correctly, as the button animation triggers and selenium proceeds the test, where it fails because it doesn't find any elements that are supposed to be on the next page.
One possible workaround would be a Thread.sleep() before clicking the button, but I'd like to avoid this solution.
I've tried this workaround where I check if redirect happened, but this just causes the page to loop and never actually load.
while(!driver.getCurrentUrl().toLowerCase().endsWith("login/checkout")) {
driver.findElement(By.cssSelector("button[data-checkout-url='/cart/checkout']")).click();
}
The button in question is this one, for example. However, this behaviour happens on multiple buttons.
<button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button"
data-checkout-url="/cart/checkout">
Checkout
</button>
The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system. The button normally only redirects you to login page.
java selenium testing automation
I'm testing a web UI using Selenium in Java. I've come to a test case where a button which links to another page is supposed to be clicked right after loading a new page.
However, sometimes when the button is clicked, no page redirect is triggered. I'm sure that the button gets clicked correctly, as the button animation triggers and selenium proceeds the test, where it fails because it doesn't find any elements that are supposed to be on the next page.
One possible workaround would be a Thread.sleep() before clicking the button, but I'd like to avoid this solution.
I've tried this workaround where I check if redirect happened, but this just causes the page to loop and never actually load.
while(!driver.getCurrentUrl().toLowerCase().endsWith("login/checkout")) {
driver.findElement(By.cssSelector("button[data-checkout-url='/cart/checkout']")).click();
}
The button in question is this one, for example. However, this behaviour happens on multiple buttons.
<button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button"
data-checkout-url="/cart/checkout">
Checkout
</button>
The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system. The button normally only redirects you to login page.
java selenium testing automation
java selenium testing automation
edited Nov 7 at 12:02
sleske
56.6k26132182
56.6k26132182
asked Nov 7 at 9:11
fugasjunior
187
187
What is there behind the button? Does it perform an HTML form submit? Does it run JavaScript? Please share the relevant HTML code.
– sleske
Nov 7 at 9:35
The exact button is following: <button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button" data-checkout-url="/cart/checkout">Checkout</button>
– fugasjunior
Nov 7 at 9:52
Thanks. In general, please edit your question if you have additional details (comments are easily overlooked and may be deleted).
– sleske
Nov 7 at 10:23
As to the button: We need more information, as I indicated in my question. Is there JavaScript attached to the button? The classes associated ("js-continue-checkout-button") seem to indicate this. Or does it just cause a standard form submit?
– sleske
Nov 7 at 10:28
Thanks for the advice, I'll edit the question. The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system and can't show you the javascript code itself. The button normally only redirects you to login page. I am just looking for a reasonable solution to ensure this button is clicked correctly and redirect happens, but I understand that it might not be possible without the knowledge of underlying javascript.
– fugasjunior
Nov 7 at 11:06
add a comment |
What is there behind the button? Does it perform an HTML form submit? Does it run JavaScript? Please share the relevant HTML code.
– sleske
Nov 7 at 9:35
The exact button is following: <button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button" data-checkout-url="/cart/checkout">Checkout</button>
– fugasjunior
Nov 7 at 9:52
Thanks. In general, please edit your question if you have additional details (comments are easily overlooked and may be deleted).
– sleske
Nov 7 at 10:23
As to the button: We need more information, as I indicated in my question. Is there JavaScript attached to the button? The classes associated ("js-continue-checkout-button") seem to indicate this. Or does it just cause a standard form submit?
– sleske
Nov 7 at 10:28
Thanks for the advice, I'll edit the question. The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system and can't show you the javascript code itself. The button normally only redirects you to login page. I am just looking for a reasonable solution to ensure this button is clicked correctly and redirect happens, but I understand that it might not be possible without the knowledge of underlying javascript.
– fugasjunior
Nov 7 at 11:06
What is there behind the button? Does it perform an HTML form submit? Does it run JavaScript? Please share the relevant HTML code.
– sleske
Nov 7 at 9:35
What is there behind the button? Does it perform an HTML form submit? Does it run JavaScript? Please share the relevant HTML code.
– sleske
Nov 7 at 9:35
The exact button is following: <button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button" data-checkout-url="/cart/checkout">Checkout</button>
– fugasjunior
Nov 7 at 9:52
The exact button is following: <button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button" data-checkout-url="/cart/checkout">Checkout</button>
– fugasjunior
Nov 7 at 9:52
Thanks. In general, please edit your question if you have additional details (comments are easily overlooked and may be deleted).
– sleske
Nov 7 at 10:23
Thanks. In general, please edit your question if you have additional details (comments are easily overlooked and may be deleted).
– sleske
Nov 7 at 10:23
As to the button: We need more information, as I indicated in my question. Is there JavaScript attached to the button? The classes associated ("js-continue-checkout-button") seem to indicate this. Or does it just cause a standard form submit?
– sleske
Nov 7 at 10:28
As to the button: We need more information, as I indicated in my question. Is there JavaScript attached to the button? The classes associated ("js-continue-checkout-button") seem to indicate this. Or does it just cause a standard form submit?
– sleske
Nov 7 at 10:28
Thanks for the advice, I'll edit the question. The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system and can't show you the javascript code itself. The button normally only redirects you to login page. I am just looking for a reasonable solution to ensure this button is clicked correctly and redirect happens, but I understand that it might not be possible without the knowledge of underlying javascript.
– fugasjunior
Nov 7 at 11:06
Thanks for the advice, I'll edit the question. The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system and can't show you the javascript code itself. The button normally only redirects you to login page. I am just looking for a reasonable solution to ensure this button is clicked correctly and redirect happens, but I understand that it might not be possible without the knowledge of underlying javascript.
– fugasjunior
Nov 7 at 11:06
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
However, sometimes when the button is clicked, no page redirect is
triggered. I'm sure that the button gets clicked correctly, as the
button animation triggers and Selenium proceeds the test, where it
fails because it doesn't find any elements that are supposed to be on
the next page.
To find a robust solution, there's probably no way around actually digging into the problem, and debugging the page to find out what exactly it normally does when the button is clicked, and why it fails in this case. Ideally, you'd want to test the page without knowing about its internals, but sometimes this is not possible.
While only debugging will truly tell you what is going wrong, I can offer an educated guess:
It seems that the page is performing additional initialization in the background after the visible part has loaded. For example, it might run JavaScript after loading which attaches event handlers to buttons. That means that there is a brief window of time after loading the page where it is not fully functional. If you hit that window during the test, weird things happen.
To correctly handle this, you will have to:
- find out what exactly is not yet "ready" in the page
- find something in the page that tells you the page is ready, such as a DIV appearing
- put code into your test (ideally into the Page Object, which you hopefully use) that waits for the page to be ready, typically using
WebDriverWait
Unfortunately, the details of how to do this will depend on the page, so you'll have to do some digging (see above :-) ). Incidentally, this type of problem is not uncommon when testing complex web applications: Often the app will do something in the background after an action (such as a page load or a button click) has completed, and you will have to wait for the "real completion" before further interacting with the page.
One possible workaround would be a Thread.sleep() before clicking the
button, but I'd like to avoid this solution.
Yes, that is a workaround, and one I have actually used. It can be a pragmatic solution if the "proper" solution outlined above is too tedious, but as you probably know, it is not a reliable solution (you never know how long to wait), and if used frequently, will slow down your tests, so I see it as an option of last resort.
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
add a comment |
up vote
-1
down vote
You can use wait.until() command to check the expected element is loaded and set maximum time to look for the element when you instantiate WebDriverWait()
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
However, sometimes when the button is clicked, no page redirect is
triggered. I'm sure that the button gets clicked correctly, as the
button animation triggers and Selenium proceeds the test, where it
fails because it doesn't find any elements that are supposed to be on
the next page.
To find a robust solution, there's probably no way around actually digging into the problem, and debugging the page to find out what exactly it normally does when the button is clicked, and why it fails in this case. Ideally, you'd want to test the page without knowing about its internals, but sometimes this is not possible.
While only debugging will truly tell you what is going wrong, I can offer an educated guess:
It seems that the page is performing additional initialization in the background after the visible part has loaded. For example, it might run JavaScript after loading which attaches event handlers to buttons. That means that there is a brief window of time after loading the page where it is not fully functional. If you hit that window during the test, weird things happen.
To correctly handle this, you will have to:
- find out what exactly is not yet "ready" in the page
- find something in the page that tells you the page is ready, such as a DIV appearing
- put code into your test (ideally into the Page Object, which you hopefully use) that waits for the page to be ready, typically using
WebDriverWait
Unfortunately, the details of how to do this will depend on the page, so you'll have to do some digging (see above :-) ). Incidentally, this type of problem is not uncommon when testing complex web applications: Often the app will do something in the background after an action (such as a page load or a button click) has completed, and you will have to wait for the "real completion" before further interacting with the page.
One possible workaround would be a Thread.sleep() before clicking the
button, but I'd like to avoid this solution.
Yes, that is a workaround, and one I have actually used. It can be a pragmatic solution if the "proper" solution outlined above is too tedious, but as you probably know, it is not a reliable solution (you never know how long to wait), and if used frequently, will slow down your tests, so I see it as an option of last resort.
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
add a comment |
up vote
1
down vote
accepted
However, sometimes when the button is clicked, no page redirect is
triggered. I'm sure that the button gets clicked correctly, as the
button animation triggers and Selenium proceeds the test, where it
fails because it doesn't find any elements that are supposed to be on
the next page.
To find a robust solution, there's probably no way around actually digging into the problem, and debugging the page to find out what exactly it normally does when the button is clicked, and why it fails in this case. Ideally, you'd want to test the page without knowing about its internals, but sometimes this is not possible.
While only debugging will truly tell you what is going wrong, I can offer an educated guess:
It seems that the page is performing additional initialization in the background after the visible part has loaded. For example, it might run JavaScript after loading which attaches event handlers to buttons. That means that there is a brief window of time after loading the page where it is not fully functional. If you hit that window during the test, weird things happen.
To correctly handle this, you will have to:
- find out what exactly is not yet "ready" in the page
- find something in the page that tells you the page is ready, such as a DIV appearing
- put code into your test (ideally into the Page Object, which you hopefully use) that waits for the page to be ready, typically using
WebDriverWait
Unfortunately, the details of how to do this will depend on the page, so you'll have to do some digging (see above :-) ). Incidentally, this type of problem is not uncommon when testing complex web applications: Often the app will do something in the background after an action (such as a page load or a button click) has completed, and you will have to wait for the "real completion" before further interacting with the page.
One possible workaround would be a Thread.sleep() before clicking the
button, but I'd like to avoid this solution.
Yes, that is a workaround, and one I have actually used. It can be a pragmatic solution if the "proper" solution outlined above is too tedious, but as you probably know, it is not a reliable solution (you never know how long to wait), and if used frequently, will slow down your tests, so I see it as an option of last resort.
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
However, sometimes when the button is clicked, no page redirect is
triggered. I'm sure that the button gets clicked correctly, as the
button animation triggers and Selenium proceeds the test, where it
fails because it doesn't find any elements that are supposed to be on
the next page.
To find a robust solution, there's probably no way around actually digging into the problem, and debugging the page to find out what exactly it normally does when the button is clicked, and why it fails in this case. Ideally, you'd want to test the page without knowing about its internals, but sometimes this is not possible.
While only debugging will truly tell you what is going wrong, I can offer an educated guess:
It seems that the page is performing additional initialization in the background after the visible part has loaded. For example, it might run JavaScript after loading which attaches event handlers to buttons. That means that there is a brief window of time after loading the page where it is not fully functional. If you hit that window during the test, weird things happen.
To correctly handle this, you will have to:
- find out what exactly is not yet "ready" in the page
- find something in the page that tells you the page is ready, such as a DIV appearing
- put code into your test (ideally into the Page Object, which you hopefully use) that waits for the page to be ready, typically using
WebDriverWait
Unfortunately, the details of how to do this will depend on the page, so you'll have to do some digging (see above :-) ). Incidentally, this type of problem is not uncommon when testing complex web applications: Often the app will do something in the background after an action (such as a page load or a button click) has completed, and you will have to wait for the "real completion" before further interacting with the page.
One possible workaround would be a Thread.sleep() before clicking the
button, but I'd like to avoid this solution.
Yes, that is a workaround, and one I have actually used. It can be a pragmatic solution if the "proper" solution outlined above is too tedious, but as you probably know, it is not a reliable solution (you never know how long to wait), and if used frequently, will slow down your tests, so I see it as an option of last resort.
However, sometimes when the button is clicked, no page redirect is
triggered. I'm sure that the button gets clicked correctly, as the
button animation triggers and Selenium proceeds the test, where it
fails because it doesn't find any elements that are supposed to be on
the next page.
To find a robust solution, there's probably no way around actually digging into the problem, and debugging the page to find out what exactly it normally does when the button is clicked, and why it fails in this case. Ideally, you'd want to test the page without knowing about its internals, but sometimes this is not possible.
While only debugging will truly tell you what is going wrong, I can offer an educated guess:
It seems that the page is performing additional initialization in the background after the visible part has loaded. For example, it might run JavaScript after loading which attaches event handlers to buttons. That means that there is a brief window of time after loading the page where it is not fully functional. If you hit that window during the test, weird things happen.
To correctly handle this, you will have to:
- find out what exactly is not yet "ready" in the page
- find something in the page that tells you the page is ready, such as a DIV appearing
- put code into your test (ideally into the Page Object, which you hopefully use) that waits for the page to be ready, typically using
WebDriverWait
Unfortunately, the details of how to do this will depend on the page, so you'll have to do some digging (see above :-) ). Incidentally, this type of problem is not uncommon when testing complex web applications: Often the app will do something in the background after an action (such as a page load or a button click) has completed, and you will have to wait for the "real completion" before further interacting with the page.
One possible workaround would be a Thread.sleep() before clicking the
button, but I'd like to avoid this solution.
Yes, that is a workaround, and one I have actually used. It can be a pragmatic solution if the "proper" solution outlined above is too tedious, but as you probably know, it is not a reliable solution (you never know how long to wait), and if used frequently, will slow down your tests, so I see it as an option of last resort.
edited Nov 7 at 12:06
answered Nov 7 at 11:57
sleske
56.6k26132182
56.6k26132182
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
add a comment |
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
Thank you for this extensive explanation! I will try to dig deeper in the web app, and in the worst case I'll just resort to using Thread.sleep.
– fugasjunior
Nov 7 at 12:25
add a comment |
up vote
-1
down vote
You can use wait.until() command to check the expected element is loaded and set maximum time to look for the element when you instantiate WebDriverWait()
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
add a comment |
up vote
-1
down vote
You can use wait.until() command to check the expected element is loaded and set maximum time to look for the element when you instantiate WebDriverWait()
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
add a comment |
up vote
-1
down vote
up vote
-1
down vote
You can use wait.until() command to check the expected element is loaded and set maximum time to look for the element when you instantiate WebDriverWait()
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));
You can use wait.until() command to check the expected element is loaded and set maximum time to look for the element when you instantiate WebDriverWait()
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.id("id1")),
ExpectedConditions.visibilityOfElementLocated(By.id("id2"))
));
answered Nov 7 at 10:34
Mohemmed Niyaz
344
344
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
add a comment |
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
How does that answer the question? The question is how to handle cases where the new page is not loaded, not how to wait for an element in the page.
– sleske
Nov 7 at 10:37
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Read carefully what he is trying to say, he doesn't want to use Thead.Sleep(), before clicking on the next button where his test case fails. So i have asked to used webdriver wait on a element for period of time and can create condition when it condition fails. In this case even if the test case fails, he will be able to put up proper comments.
– Mohemmed Niyaz
Nov 7 at 11:46
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Yes, you can use WebDriverWait to wait on an element - but I still fail to see how that helps. What element should OP wait on? And why?
– sleske
Nov 7 at 12:00
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
Wait for any element on the next page that he is trying load.
– Mohemmed Niyaz
Nov 7 at 12:26
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
When the problem in question happens, the page never loads, as the redirect never gets triggered. Thus, no element on the next page can ever be found.
– fugasjunior
Nov 7 at 12:46
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186399%2fselenium-clicking-button-registered-but-not-redirecting-page-to-target-link%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
What is there behind the button? Does it perform an HTML form submit? Does it run JavaScript? Please share the relevant HTML code.
– sleske
Nov 7 at 9:35
The exact button is following: <button class="btn btn-primary btn-block btn--continue-checkout js-continue-checkout-button" data-checkout-url="/cart/checkout">Checkout</button>
– fugasjunior
Nov 7 at 9:52
Thanks. In general, please edit your question if you have additional details (comments are easily overlooked and may be deleted).
– sleske
Nov 7 at 10:23
As to the button: We need more information, as I indicated in my question. Is there JavaScript attached to the button? The classes associated ("js-continue-checkout-button") seem to indicate this. Or does it just cause a standard form submit?
– sleske
Nov 7 at 10:28
Thanks for the advice, I'll edit the question. The button is handled by javascript, however as I'm only testing the UI, I don't have deep knowledge of the system and can't show you the javascript code itself. The button normally only redirects you to login page. I am just looking for a reasonable solution to ensure this button is clicked correctly and redirect happens, but I understand that it might not be possible without the knowledge of underlying javascript.
– fugasjunior
Nov 7 at 11:06