Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-10 Thread Malintha Fernando
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 present and then fail
the test based on it you can use following.



*Assert.assertTrue(driver.findElements(By.id("identifier")).size() == 0);*
- BR
Malintha


On Wed, Feb 10, 2016 at 11:53 AM, Dharshana Warusavitharana <
dharsha...@wso2.com> wrote:

> 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].
> https://rameshbaskar.wordpress.com/2013/09/11/soft-assertions-using-testng/
>
> Thank you,
> Dharshana.
>
> On Tue, Feb 9, 2016 at 5:32 PM, Madhawa Perera  wrote:
>
>> 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 true;
>> } else {
>> //System.out.println("false");
>> return false;
>> }
>> }
>>
>> Hope this will help you. Check the following [1] reference too.
>>
>> [1]
>> http://stackoverflow.com/questions/6521270/webdriver-check-if-an-element-exists
>>
>> Regards,
>> Madhawa
>>
>>
>> On Tue, Feb 9, 2016 at 4:32 PM, Lahiru Cooray  wrote:
>>
>>> 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
>>> waiting time in seconds
>>>
>>> for (int i = 0; i < 2; i++) {
>>> try {
>>>
>>> tempWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
>>> "a[href*='/store/assets/webapp/" + appId +
>>> "']")));
>>> driver.navigate().refresh();
>>> break;
>>> } catch (org.openqa.selenium.TimeoutException e) {
>>> //Expected error when no element found
>>> }
>>> }
>>>
>>> Here i'm trying two times and waiting a fair time to load the element.
>>>
>>>
>>> On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake 
>>> 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 
> 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

Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-10 Thread Lahiru J Ekanayake
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
overcome ,

1. we need to implement have separate method using
*driver.findElement(By.id("**identifier**"))*

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/BaseUITestCase.java#L82


2. Next way is to use *driver.findElements(By.id("identifier")).size() . * This
method will return 0 (zero) even if such a element is not present. We do
not need to use try block here. It will not throw an exception.


Regards.

On Wed, Feb 10, 2016 at 7:32 PM, Malintha Fernando 
wrote:

> 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 present and then fail
> the test based on it you can use following.
>
>
>
> *Assert.assertTrue(driver.findElements(By.id("identifier")).size() == 0);*
> - BR
> Malintha
>
>
> On Wed, Feb 10, 2016 at 11:53 AM, Dharshana Warusavitharana <
> dharsha...@wso2.com> wrote:
>
>> 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].
>> https://rameshbaskar.wordpress.com/2013/09/11/soft-assertions-using-testng/
>>
>> Thank you,
>> Dharshana.
>>
>> On Tue, Feb 9, 2016 at 5:32 PM, Madhawa Perera  wrote:
>>
>>> 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 true;
>>> } else {
>>> //System.out.println("false");
>>> return false;
>>> }
>>> }
>>>
>>> Hope this will help you. Check the following [1] reference too.
>>>
>>> [1]
>>> http://stackoverflow.com/questions/6521270/webdriver-check-if-an-element-exists
>>>
>>> Regards,
>>> Madhawa
>>>
>>>
>>> On Tue, Feb 9, 2016 at 4:32 PM, Lahiru Cooray  wrote:
>>>
 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
 waiting time in seconds

 for (int i = 0; i < 2; i++) {
 try {

 tempWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
 "a[href*='/store/assets/webapp/" + appId +
 "']")));
 driver.navigate().refresh();
 break;
 } catch (org.openqa.selenium.TimeoutException e) {
 //Expected error when no element found
 }
 }

 Here i'm trying two times and waiting a fair time to load the element.


 On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake 
 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 
>> wrote:
>>

[Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Lahiru J Ekanayake
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


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Krishantha Samaraweera
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 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.
>
>


-- 
Krishantha Samaraweera
Senior Technical Lead - Test Automation
Mobile: +94 77 7759918
WSO2, Inc.; http://wso2.com/
lean . enterprise . middleware.
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Lahiru J Ekanayake
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 
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 
> 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 *
>
> *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


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Ayesha Dissanayaka
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  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  > 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 
>> 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 *
>>
>> *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

20, Palmgrove Avenue, Colombo 3
E-Mail: aye...@wso2.com 
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Lahiru Cooray
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 waiting
time in seconds

for (int i = 0; i < 2; i++) {
try {

tempWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
"a[href*='/store/assets/webapp/" + appId + "']")));
driver.navigate().refresh();
break;
} catch (org.openqa.selenium.TimeoutException e) {
//Expected error when no element found
}
}

Here i'm trying two times and waiting a fair time to load the element.


On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake  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  > 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 
>> 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 *
>>
>> *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
>
>


-- 
*Lahiru Cooray*
Software Engineer
WSO2, Inc.;http://wso2.com/
lean.enterprise.middleware

Mobile: +94 715 654154
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Rajeenthini Satkunam
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  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 *

*M :+94770832823   *
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Madhawa Perera
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 true;
} else {
//System.out.println("false");
return false;
}
}

Hope this will help you. Check the following [1] reference too.

[1]
http://stackoverflow.com/questions/6521270/webdriver-check-if-an-element-exists

Regards,
Madhawa


On Tue, Feb 9, 2016 at 4:32 PM, Lahiru Cooray  wrote:

> 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 waiting
> time in seconds
>
> for (int i = 0; i < 2; i++) {
> try {
>
> tempWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
> "a[href*='/store/assets/webapp/" + appId + "']")));
> driver.navigate().refresh();
> break;
> } catch (org.openqa.selenium.TimeoutException e) {
> //Expected error when no element found
> }
> }
>
> Here i'm trying two times and waiting a fair time to load the element.
>
>
> On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake 
> 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 
>>> 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 *
>>>
>>> *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
>>
>>
>
>
> --
> *Lahiru Cooray*
> Software Engineer
> WSO2, Inc.;http://wso2.com/
> lean.enterprise.middleware
>
> Mobile: +94 715 654154
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Madhawa Perera
*Software Engineer*
Mobile : +94 (0) 773655496
<%2B94%20%280%29%20773%20451194>
madha...@wso2.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Lahiru J Ekanayake
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 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 waiting
> time in seconds
>
> for (int i = 0; i < 2; i++) {
> try {
>
> tempWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
> "a[href*='/store/assets/webapp/" + appId + "']")));
> driver.navigate().refresh();
> break;
> } catch (org.openqa.selenium.TimeoutException e) {
> //Expected error when no element found
> }
> }
>
> Here i'm trying two times and waiting a fair time to load the element.
>
>
> On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake 
> 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 
>>> 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 *
>>>
>>> *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
>>
>>
>
>
> --
> *Lahiru Cooray*
> Software Engineer
> WSO2, Inc.;http://wso2.com/
> lean.enterprise.middleware
>
> Mobile: +94 715 654154
>



-- 



*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


Re: [Dev] Selenium UI Testing [GREG/ES - Publisher]

2016-02-09 Thread Dharshana Warusavitharana
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].
https://rameshbaskar.wordpress.com/2013/09/11/soft-assertions-using-testng/

Thank you,
Dharshana.

On Tue, Feb 9, 2016 at 5:32 PM, Madhawa Perera  wrote:

> 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 true;
> } else {
> //System.out.println("false");
> return false;
> }
> }
>
> Hope this will help you. Check the following [1] reference too.
>
> [1]
> http://stackoverflow.com/questions/6521270/webdriver-check-if-an-element-exists
>
> Regards,
> Madhawa
>
>
> On Tue, Feb 9, 2016 at 4:32 PM, Lahiru Cooray  wrote:
>
>> 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
>> waiting time in seconds
>>
>> for (int i = 0; i < 2; i++) {
>> try {
>>
>> tempWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
>> "a[href*='/store/assets/webapp/" + appId +
>> "']")));
>> driver.navigate().refresh();
>> break;
>> } catch (org.openqa.selenium.TimeoutException e) {
>> //Expected error when no element found
>> }
>> }
>>
>> Here i'm trying two times and waiting a fair time to load the element.
>>
>>
>> On Tue, Feb 9, 2016 at 3:34 PM, Lahiru J Ekanayake 
>> 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 
 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 *

 *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
>>>
>>>
>>
>>
>> --
>> *Lahiru