How to make selenium script to work with angular js

804 views
Skip to first unread message

shruthi v v

unread,
Jan 27, 2016, 5:55:25 AM1/27/16
to seleniu...@googlegroups.com
Hello all,

  My requirement is to make my selenium TestNg scripts to be supported for new framework  "angular js".What are the possible ways to achieve this? 

     Do I need to write complete new code or I can just modify existing code.Could some one provide me what action to be taken?As I heard that web page elements will be like " ng-name" and this element locator is not supported by selenium.


Help is highly appreciated.








Thanks
Shruthi

Arnab Patra

unread,
Jan 27, 2016, 6:01:53 AM1/27/16
to Selenium Users
Hi shruthi,
I am also working on same kind of scenario.From last 2 months i am developing script with anjular Js here the only tricks i am following that is i am using relative xpath and inside the xpath i am using the unique ng property value.

shruthi v v

unread,
Jan 27, 2016, 6:41:06 AM1/27/16
to seleniu...@googlegroups.com
Great Arnab Patra!

 Could you please share with me one such example on how to include unique ng property value in Xpath.and is it only possible with xpath or it can be done for other locators to if any.

If you are following any tutorial sites related to angular js,please mention 














Shruthi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e8c2e937-fd7d-456b-b607-408a39b977fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Collin

unread,
Jan 27, 2016, 9:58:56 AM1/27/16
to Selenium Users
AngularJS is just a framework that generates HTML.

Just get your devs to stick an ID on things that are of interest.

The only thing that you may need to do when writing tests for an angular site is add an Explicit Wait that detects if angular has finished processing.

Shawn Knight

unread,
Jan 29, 2016, 1:04:18 PM1/29/16
to Selenium Users
We solved this issue with angular by using data-* attributes, because our developers use IDs for their own purposes, they could be subjected to changes -- Addition, we did not want to couple our elements to angular attributes, like ng-name -- i wrote a blog on the subject -- http://simpleseleniumnotes.blogspot.com/2015/10/simplify-locators-with-html-data.html

Serguei Kouzmine

unread,
Feb 4, 2016, 10:07:08 PM2/4/16
to Selenium Users
You can integrate your java tests with Protractor client API  in Java:

See https://github.com/sergueik/jProtractor

we have not pushed the jar to maven central yet, so you have to install it locally by building the project from source. I have provided a big number of integration tests there. I used nunit, it is easy to work with testng if you prefer so.

and you may find it useful to read http://www.codeproject.com/Articles/1066968/Developing-Protractor-tests-in-Csharp-or-Java

Thanks, let me know if any questions,
Serguei Kouzmine

shruthi v v

unread,
Feb 8, 2016, 8:12:04 AM2/8/16
to seleniu...@googlegroups.com
Could you please tell the steps how to integrate my java tests with Protractor client API  in Java?I have downloaded the zip file from https://github.com/sergueik/jProtractor .














Shruthi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

shruthi v v

unread,
Feb 8, 2016, 12:17:53 PM2/8/16
to seleniu...@googlegroups.com

Waiting for the response on this .I couldn't figure out how to do it myself. Please help me in integrating this.

shruthi

Krishnan Mahadevan

unread,
Feb 8, 2016, 12:21:22 PM2/8/16
to Selenium Users
Sruthi,
Not sure what exactly are you expecting as help here.
You should ideally speaking be reaching out directly to the owner of the library you called out, than asking for help on a library on Selenium/WebDriver forum. 
This forum is intended for Selenium/WebDriver related queries only. Please help keep this forum relevant.


On a side note, I quickly looked up the library and its a maven project. So what exactly is your issue in adding it up as a dependency in your pom file and then working with it ? If you aren't sure how to consume a maven artifact (or) don't know how to work with Maven, you can google up and refer to any of the tutorials for that.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

durai

unread,
Feb 8, 2016, 12:34:56 PM2/8/16
to Selenium Users
Hi Shruti,

look in to the below link 

Serguei Kouzmine

unread,
Feb 8, 2016, 8:59:09 PM2/8/16
to seleniu...@googlegroups.com
Hello Shruthi


One way to start  using the jprotractor is:

Assume you have the app,  which compiles into a jar and runs
@Test
testAddCustomer();
and you want to use those Proractor NgBy's:

ngDriver.findElement(NgBy.buttonText("Bank Manager Login")).click();
        ngDriver.findElement(NgBy.partialButtonText("Add Customer")).click();

        WebElement firstName = ngDriver.findElement(NgBy.model("fName"));
        assertThat(firstName.getAttribute("placeholder"), equalTo("First Name"));
        firstName.sendKeys("John");
...
...

You package jprotractor.jar

set travis=true
mvn clean package

and copy it to the src/main/resources of your project (that I describe above). You add it to pom:
  <properties>
    <jprotractor.version>1.0-SNAPSHOT</jprotractor.version>
...
   </properties>

    <dependency>
     <groupId>com.jprotractor</groupId>
     <artifactId>jprotractor</artifactId>
     <version>${jprotractor.version}</version>
     <scope>system</scope>
     <systemPath>${project.basedir}/src/main/resources/jprotractor-${jprotractor.version}.jar</systemPath>
    </dependency>

and to class source:
import com.jprotractor.NgBy;
import com.jprotractor.NgWebDriver;
import com.jprotractor.NgWebElement;

and add it to class path when running the jar,  together with the path to standalone Selenium jar:

mvn clean package

set TARGET=%CD%\target
set SELENIUM_HOME=c:\java\selenium
set SELENIUM_VERSION=2.44.0
set APP_VERSION=0.1-SNAPSHOT
set PROTRACTOR_VERSION=1.0-SNAPSHOT
set MONTE_VERSION=1.0
set M2_REPOSITORY=%USERPROFILE%\.m2\repository
set MAVEN_OPTS=-Xms256m -Xmx512m

set LAUNCHER_OPTS=-XX:PermSize=512M -XX:MaxPermSize=512M -Xmn128M -Xms512M -Xmx5
12M

java.exe %LAUNCHER_OPTS%  -cp ^
target\app-%APP_VERSION%.jar;^
src\main\resources\jprotractor-%PROTRACTOR_VERSION%.jar;^
%M2_REPOSITORY%\com\pojosontheweb\monte-repack\%MONTE_VERSION%\monte-repack-%MON
TE_VERSION%.jar;^
%SELENIUM_HOME%\selenium-server-standalone-%SELENIUM_VERSION%.jar;^
target\lib\* ^
com.mycompany.app.App


What I describe you can find in my github project
https://github.com/sergueik/selenium_java/tree/master/protractor-test

Note : protractor-test is kind of scratch project it may have unrelated code which you can safely remove. If you need a Linux version of the same, let me know and I provide

Note : i am about to add these instructions to README.md soon


Let me know if you can start with that and move forward.

Serguei Kouzmine

Confidentiality Notice: The above information contained in this email is intended for the confidential use of the above-named recipient(s). If a reader of this message is not the intended recipient or person responsible for delivering it to the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this in error, please notify the sender immediately and destroy this message.**

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/CM4HAdbbWb4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

shruthi v v

unread,
Feb 9, 2016, 1:32:45 AM2/9/16
to seleniu...@googlegroups.com

Thanks for krishnan mahadevan,durai.
But I was expecting response from serguei kouzmine for the solution.

Serguei kouzmine,

  I using selenium TestNg project and ant as build generation tool,not configured my project with maven so any help for my project ?
shruthi

shruthi

You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Serguei Kouzmine

unread,
Feb 9, 2016, 11:10:47 AM2/9/16
to Selenium Users
Hello Shruthi

Please grab the project
https://github.com/sergueik/selenium_java/tree/master/protractor-test/ant


Please put all jars into the directory c:\java\selenium:

 Directory of c:\java\selenium

02/08/2016  08:51 PM            29,663 jprotractor-1.0-SNAPSHOT.jar
11/09/2014  11:33 AM            37,875 json-20080701.jar
10/29/2014  06:21 PM           489,883 log4j-1.2.17.jar
10/30/2014  07:32 PM        35,169,724 selenium-server-standalone-2.44.0.jar

and

ant  clean test

Thanks

Serguei Kouzmine

On Wednesday, January 27, 2016 at 5:55:25 AM UTC-5, shruthi v v wrote:

Vanshdeep Kewlani

unread,
Feb 10, 2016, 12:07:58 AM2/10/16
to Selenium Users
Hi Serguei,

I tried to compile the code shared by you but got some errors and I am not aware how to fix them as they were mainly related to Angular. I was planning to compile your code base and use it as a library in the form of JAR in my project but could not proceed further because of this.

Also, I have  a query regarding JProtractor - if I refer the JProtractor site, it is specifically mentioned over there in section "Can I use it" as Nope which is leading me to confusion as to how come you are suggesting a way of using it.


Thank you & Regards,
Vanshdeep Kewlani


On Wednesday, January 27, 2016 at 4:25:25 PM UTC+5:30, shruthi v v wrote:

shruthi v v

unread,
Feb 10, 2016, 1:26:56 AM2/10/16
to seleniu...@googlegroups.com
Serguei Kouzmine ,

Where can I find jprotractor jar that you have mentioned here? 02/08/2016  08:51 PM    29,663 jprotractor-1.0-SNAPSHOT.jar
I tried to download from google but did't found it.

When I checked for this link(https://github.com/sergueik/selenium_java/tree/master/protractor-test/ant)
,it seems to be it is not a project ,I could not download ant folder alone hence I have downloaded "selenium_java-master" zip file and then added necessary files like "buil.xml","testng.xml" and complete src folder (which contains "Program.java" file) but it is giving me import statements errors like below as I have not added 
jprotractor jar file 

1.The import com.jprotractor can not be resolved

Please tell me jprotractor jar file download location or how to resolve this issue?

















Shruthi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Krishnan Mahadevan

unread,
Feb 10, 2016, 1:31:08 AM2/10/16
to Selenium Users
Serguei 

You might perhaps want to create a new google forum for all the artifacts that you own, update your github repository's readme.md file to provide a link to the google forum and have your artifact users post queries in that forum. That way, you can focus on just that forum for all your artifact queries.

I believe that most of the queries are all specific to your artifact and thus IMHO it doesnt make sense to have them be posted on the WebDriver/Selenium Users google forums.

That's just my 2 cents on this!






Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

Serguei Kouzmine

unread,
Feb 10, 2016, 8:42:57 AM2/10/16
to Selenium Users

Hello Shruthi

I added detailed `target\jprotractor-1.0-SNAPSHOT.jar` build instructions  to the README : https://github.com/sergueik/jProtractor/blob/master/README.md


Serguei Kouzmine
On Wednesday, January 27, 2016 at 5:55:25 AM UTC-5, shruthi v v wrote:

Krishnan Mahadevan

unread,
Feb 10, 2016, 8:48:40 AM2/10/16
to Selenium Users
Serguei,

I would recommend that you please consider creating a new google forum for all of your artifacts, and have your README.md file updated to refer to the forum.

That way, the selenium/webdriver forums wouldn't be taking in queries related to your artifact and you also stand benefited of having a focused attention to the users of your artifacts.

Does that sound like a fair ask ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Serguei Kouzmine

unread,
Feb 10, 2016, 10:47:49 AM2/10/16
to Selenium Users
Hello Krishna


I think this is an excellent plan

Do you think

Protractor Java and c# Client
https://groups.google.com/d/forum/protractor-java--c-client
would be a good name..

Thanks,


Serguei Kouzmine


On Wednesday, January 27, 2016 at 5:55:25 AM UTC-5, shruthi v v wrote:

Serguei Kouzmine

unread,
Feb 10, 2016, 10:58:13 AM2/10/16
to Selenium Users


On Wednesday, January 27, 2016 at 5:55:25 AM UTC-5, shruthi v v wrote:

BALAJI SINGH

unread,
Sep 20, 2016, 9:55:29 AM9/20/16
to Selenium Users
Hi Shruti,

Please let me know if you have implemented Jprotractor.

 I need your help on this Jprotractor stuff. 

My Email is : bal...@gmail.com and my contact number is +917676823622.

With Regards,
Balaji Singh


On Wednesday, January 27, 2016 at 4:25:25 PM UTC+5:30, shruthi v v wrote:

ankit garg

unread,
Sep 20, 2016, 10:44:15 AM9/20/16
to seleniu...@googlegroups.com
Hi All,

I am also looking forward to use JProtactor.Please share information on how to get started with this.

Regards,
Ankit Garg

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/965eb4c8-6735-4786-bfcd-a8686731a827%40googlegroups.com.

Serguei Kouzmine

unread,
Jul 15, 2017, 6:16:02 PM7/15/17
to Selenium Users
Hello 

Sorry for missing this post. There is  a few sample project in jProtractor directory where i show how to use it. 

Please confirm if there
 is  still some challenge with getting started

Thanks
Serguei Kouzmine  (one of developers of jprotractor)

On Wednesday, January 27, 2016 at 5:55:25 AM UTC-5, shruthi v v wrote:
Reply all
Reply to author
Forward
0 new messages