Check xpath element exist in opened webpage using workfusion studio conditional action.
Currently i'm using webelement Actions Library to login on specific website. its working fine.
But when i already logined then its give me an error on login steps because its redirected on home page directly.
So, I want to check if Xpath element is exist on my webpage or not.
To accomplish a check, you can create an Exception Handling block, and put a Mouse Click by this XPath inside the "Try to completeā block.
Alternatively, you can use the Retry block or add more Wait time
Related
This is my scenario "i am submitting the form and once I submit its navigate into page call WebTable.I want to confirm now am incorrect page after submitting the form"
how to check this by using assertion? please help selenium /Java /TestNG
In my experience, you have basically two options available to you.
Wait for the URL to contain what you expect using driver.getCurrentUrl()
Wait for a specific element that will only appear on the next page
If you don't have a class already built for performing retries, you can use FluentWait.
Once you click the form you wait for an element to show up using Webdriverwait.
You pull the current URL and check with value and assert it.
submitBtn.click();
WebDriverWait(driver,10).until(ExpectedConditions.visibilityOfElementLocated(By.id("etc")));
expectedUrl = driver.getCurrentUrl();
Assert.assertTrue(expectedUrl.equals("something"));
Selenium provides a good practice for this type of validation, and here comes FluentWait:
FluentWait fluentWait = new FluentWait(webDriverBPO).withTimeout(Duration.ofSeconds(20)).pollingEvery(Duration.ofSeconds(1)).ignoring(NullPointerException.class);
All you have to do after your last action, is to wait until URL contains your expected value:
fluentWait.until(ExpectedConditions.urlContains("your URL or keyword from URL"));
You can try also to wait for any element from the new page, but the URL loads faster than the content, so you will save some time (as you don't need to perform any other validations).
I have login form on website,
i want to make automatic testcase for this scenario:
i give phone number but no password:
How do I test selenium to give me expected red error message popup?
What function is in selenium api to check for it? I did not find it!
EDIT: or maybe my expected thing to happen should be "stay on same page"?
There is no specific function like that. Find out what is the xpath for that red colored text. Then you can create a web element using that xpath and check whether it is visible and what is the text value of that element, and assert on that.
As an example:
You first define the error message WebElement as messageElement
You may locate the element like this:
driver.findElement(By.id("error-message"))
Then you may get the error message text using this:
messageElement.getText());
Once you get the text you can then validate it with the expected text.
Assert.assertEquals(actualMessage, expectedMessage);
PS:
From snap, it doesn't seem to be another pop-up so no need to use switch to alert etc.
I have code in a desribe block but some of my set up code is outside of the block. That's the code that sets up elements.
When my code executes it runs fine but then I see the browser go to another page before parts of my test have completed. With a different page on the browser then it looks for elements and throws an exception when they are not there.
So how can I handle this problem of the browser going to another page before tests are completed?
As per my understanding of the question you want to be on the same page and don't want to move to the new page which loads when you click on to a link/button. If this is the case then to be on the same page you cane use.
Use this command -String oldwindow=window.getWindowHandle();
window.switchTo().window(oldwindow);
Use this command just below the button code which throws a new window. I am a java programer thats why the code written is in java.
getWindowHandle Methods stores the url of current window in oldwindow string and by using window.switchTo().window(oldwindow) it won't move to new window because you are passing oldwindow as argument for the command.
For more go through the Webdriver documentation by clicking this link
I have a button that executes an Ajax request and then it successfully redirects to another page.
How do I assert that the redirected page was successfully reached?
I have a clickAndWait on the button. But after that..?
you can use verifyTextPresent command to verify a unique lable or text in the redirected page.by that way you can fix you have successfully reached the redirected page.
try like this
command : verifyTextPresent
Target : some unique text in the redirected page.
i think your problem can be fixed by this.
IDE has many assert commands. You can use any of the one and you can achieve the test scope(here the page is navigated or not).
Example:
command : assertTitle
Target : check the title of the page.
In the above he used verifyTextPresent it will check weather the text is present or not in the page and it will continue the next step. If you use assert commands it will proceed the next step when the assert step is passed. Otherwise it fails.
One thing you keep in mind, selenium won't wait for Ajax kind of loading, it will wait for the Page loading. So, you have to put Wait commands explicitly to finish the Ajax loading.
You can get moreassertions when you convert the selenese code into the preferred language and testing framework. You can see that option in the Option tab in the IDE.
For more info on AssertCommands in SIDE
My site has a link which navigate to another site. I have to check whether the link taking the user to correct website. The following is the code i've written to pass control
selenium.click("link=target window");
selenium.selectWindow("Title of target window");
assertTrue((selenium.isTextPresent("content in target window")));
selenium.close();
selenium.selectWindow("null");
But if i run this i'm getting error like "Could not find window with title ... "
There is information about how the selectWindow() function locates the window here. In particular,
If you're having trouble figuring out what is the name of a window
that you want to manipulate, look at the selenium log messages which
identify the names of windows created via window.open (and therefore
intercepted by selenium). You will see messages like the following for
each window as it is opened:
debug: window.open call intercepted;
window ID (which you can use with selectWindow()) is "myNewWindow"