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- Integration Test] Custom WebDriver Class for UI test Automation
   -
   [Dev][ES] Selenium UI Integration Test Generation
   - Dev] Reduce the execution speed of Web Driver

[1]
https://github.com/wso2/product-es/blob/514b439c0b608bca4cca81f7c588a7dfeec598ad/modules/integration/tests-ui-integration/ui-test-utils/src/main/java/org/wso2/es/ui/integration/util/ESWebDriver.java#L74

Thanks!
-Ayesha



On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake <lahi...@wso2.com> wrote:

> 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 kind of
> method already in selenium.
> Thank you for your help.
>
> Regards
>
> On Tue, Feb 9, 2016 at 3:13 PM, Rajeenthini Satkunam <rajeenth...@wso2.com
> > wrote:
>
>> 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 it will help you.
>>
>> For your reference
>>
>> [1] -
>> https://github.com/wso2/product-ds/blob/master/modules/integration/tests-ui-integration/ui-test-utils/src/main/java/org/wso2/ds/ui/integration/util/DSWebDriver.java#L47
>>
>> On Tue, Feb 9, 2016 at 3:01 PM, Lahiru J Ekanayake <lahi...@wso2.com>
>> wrote:
>>
>>> 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. Problem is if that element is not
>>> exist , it will return an error, saying
>>> *org.openqa.selenium.NoSuchElementException: Unable to locate
>>> element:{"method":"id","selector":"elemnt_id"}*
>>>
>>> Is there any way to check the existence of any element , without
>>> catching the error? .
>>>
>>>
>>>
>>>
>>> Regards
>>>
>>>
>>>
>>> --
>>>
>>>
>>>
>>> *Lahiru J Ekanayake**Software Engineer*
>>> Mobile : +94 (0) 77 8812629 / +94(0) 778509547
>>> Email : lahi...@wso2.com
>>> WSO2, Inc.; http://wso2.com/
>>> lean . enterprise . middleware.
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>>
>> *Thank You.*
>>
>> *Rajeenthini Satkunam*
>>
>> *Associate Software Engineer | WSO2*
>>
>>
>> *E:rajeenth...@wso2.com <rajeenth...@wso2.com>*
>>
>> *M :+94770832823 <%2B94770832823>   *
>>
>>
>
>
> --
>
>
>
> *Lahiru J Ekanayake**Software Engineer*
> Mobile : +94 (0) 77 8812629 / +94(0) 778509547
> Email : lahi...@wso2.com
> WSO2, Inc.; http://wso2.com/
> lean . enterprise . middleware.
>
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Ayesha Dissanayaka*
Software Engineer,
WSO2, Inc : http://wso2.com
<http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg>
20, Palmgrove Avenue, Colombo 3
E-Mail: aye...@wso2.com <ayshsa...@gmail.com>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to