Hi Lahiru,
Instead of using *driver.findElement(By.id(""))* you can use
*driver.findElements(By.id(""))
*which returns a List of elements. So you can check the size of the List.
It doesn't fail the test even though elements are not existing.
if you want to check whether there are any elements
Hi All,
Thank you all for contribution. I was able to find two ways to solve above
main question, with our thread discussion. Generally in selenium,
driver.findElement() returns a type of WebElement, if there is such element
present. If there is no such an element it will throw an exception. To
Hi ,
I'm writing selenium tests for GREG publisher UI. When implementing UI test
cases, some situations we need to check whether some elements exists,
before click or make any operations on them.
Selenium provides, *driver.findElement(By.id("elemnt_id")) *
method to find any element by id.
You can use WebDriverWait
see -
http://stackoverflow.com/questions/7991522/selenium-webdriver-test-if-element-is-present
Thanks,
Krishantha.
On Tue, Feb 9, 2016 at 3:01 PM, Lahiru J Ekanayake wrote:
> Hi ,
>
> I'm writing selenium tests for GREG publisher UI. When
Hi ,
I have already tried with wait.until method. It will also return timeout
exception searching after given timeout. I think anyway we have to use try
block to check existences of an element. I have looked for a method that
returns ture/false on a given element existence . I'm not sure that
Hi Lahiru,
As Rajeenthini has mentioned above, in product-es also we have written a
method *isElementPresent* to check the existence of an element by wrapping
the try-catch at *findElement *method.
Further, Below mail threads may be helpful for you while writing Selenium
UI test.
- [ES-
Hi Lahiru,
I have faced the similar issue and I noticed that some times the
dynamically loaded elements are not loading when we are using wait.until()
without a driver refresh() So I used a similar code snipped like this:
WebDriverWait tempWait = new WebDriverWait(driver, 5); //5 is the
Hi lahiru,
If you need to check that element is present in the current UI, You can go
with this method *isElementPresent(By by)*.
for example in your case *driver.**isElementPresent**(By.id("elemnt_id")) *will
return true if the element is present in current UI or else it will return
false.Hope
Hi Lahiru,
Try following code snippet, if you are looking for a method, that returns
true/false when checking the existence of an element.
private boolean isElementPresent(By by) {
if(driver.findElements(by).size() != 0){
//System.out.println("true");
return
Hi Ayesha,
Currently I have not included ESWebDriver . I have used default selenium
WebDriver. Now i can integrate ESWebDriver to implement Selenium UI tests.
Thank you.
On Tue, Feb 9, 2016 at 4:32 PM, Lahiru Cooray wrote:
> Hi Lahiru,
>
> I have faced the similar issue and
Hi Lahiru,
You can use TestNg soft assert for this.
Basically what you want is
1. Check the element whether it is exists.
2. It should not make assert fail and stop the test execution if element is
not there.
please refer [1] for soft assert.
[1].
11 matches
Mail list logo