123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

What If Selenium's Highlight Command Was Always On?

By Author: Siyaram Ray
Total Articles: 356

Be that as it may, by utilizing reflection to naturally create code for a java class we can run the feature charge preceding executing other Selenium summons, without altering our current tests. Also, answer the inquiry, "Consider the possibility that Selenium's Highlight Command was dependably on”.

The Question:-

Have gotten heaps of extraordinary inquiries from individuals learning Selenium, the vast majority of these answers included, yet some arrangement with through private messages and blog entries. For this situation a peruser requested proposals on the best way to utilize Selenium's "Feature" charge.

The feature order in Selenium accepts a locator as a parameter and flashes the control yellow. A little assistant capacity added to help troubleshooting so you have some sign of what components your content contacts.

Presently by and by don't utilize the feature work. Never truly have. When we troubleshoot, venture through the content in Eclipse. If this technique for investigating doesn't uncover the issue then a high likelihood exists that my issues identify with a planning issue (venturing through modifies the planning of the test so here and there you can't uncover the issue that way).

Can perceive any reason why you should need to feature the locator components being used at the time and mistake occurs, on the off chance that you take Selenium Training in Bangalore screen captures naturally when a test comes up short.

The Approach:-

One simple approach to retrofit the feature summon into your tests includes expanding the DefaultSelenium class. What's more, as opposed to fabricate this HighlighterSelenium class by hand, imagined that it would bode well to create the class naturally

This would have the focal points that:

• Whatever variant of Selenium I utilize, the created code will coordinate it
• Don't need to troubleshoot each individual message
• Find it more intriguing to compose code age code than wrapper code

In the event that you haven't utilized Reflection in Java at that point will give a speedy outline. In Java reflection enables us to get to the class definitions, so as opposed to making a case of a class as a question and calling strategies on the protest. Can get to the class definition and see what strategies the class bolsters, get arrangements of the parameters and so forth.

As a snappy illustration, if need to get every one of the constructors for a class

• Class seleniumClass = DefaultSelenium.class;
• Constructor[] allConstructors = seleniumClass.getDeclaredConstructors());

And afterward can spin through the variety of constructors and show them.
So to manufacture the code for HighlighterSelenium will essentially imitate the constructors and techniques on DefaultSelenium, and for every strategy need to feature: include something like the accompanying as the body of the technique:

highlight(locator); super.methodName(locator);
e.g.
open void click(java.lang.String p0){highlight(p0);super.click(p0);}

Won't physically code it like this, would utilize imports in the class record and additionally separating and space, however with code age I don't need to stress excessively considerably over the human tasteful response to the code.

The Implementation:-

In the connected source code organizer you will discover a BuildSeleniumLocatorHighlighter.java class.

This contains a test which when run, will yield to stdout the code for HighlighterSelenium, naturally produced from whatever adaptation of the Selenium shake you have related with the venture.

So to utilize this, in the event that you to need to encounter "The Day Selenium Highlight Took Over" (illustration accept you utilize obscure):

• download the source code document
• add BuildSeleniumLocatorHighlighter.java to a task all setup with tests and Selenium libraries in the construct way
• run the reflectThroughSelenium test
• copy the yield from stdout in the support into another class document "HighlighterSelenium.java"
• in your tests, rather than making an occurrence of DefaultSelenium, make an occasion of HighlighterSelenium
• then run your tests

My Answer:-

Having done this and run my tests, didn't feel like we got any genuine advantage from the feature charge. If at any time do need selenium courses in Bangalore to utilize it at that point will uncover HighlighterSelenium class as that may help, and in any event implies I don't need to do any coding work to alter my tests to feature the locators.

In the event that you take a gander at the created source code you will see that a portion of the techniques don't have feature code - these either don't utilize a locator, or the client does not anticipate that it will toss an exemption when the locator does not discover a component.
The BuildSeleniumLocatorHighlighter.java class ought to likewise go about as a decent prologue to reflection.

Tip:

Will all the time compose little applications and contents like this as "tests" in Java. Along these lines can run them effortlessly from the shroud right snap menu. It appears a simple method to get the adhoc scripting benefits that individuals get from Ruby and Perl.

More About the Author

best institute for selenium training in Bangalore – Infocampus. Infocampus is an excellence training center for selenium courses in Bangalore. At Infocampus, selenium training is focused on practical and real time examples. Contact Infocampus at 8884166608 or visit http://infocampus.co.in/best-selenium-testing-training-center-in-bangalore.html for complete details on selenium training.

Total Views: 31Word Count: 793See All articles From Author

Computer Programming Articles

1. Test Automation – Importance Of Selenium Ide With Features
Author: Siyaram ray

2. The Effect Of Chicken Cage On Temperature Regulation Of Chicken House
Author: The effect of chicken cage on temperature regulati

3. The Chicken House Needs Ventilation
Author: The chicken house needs ventilation

4. Automation Testing - Instructions For Integrating Jenkins With Selenium Webdriver
Author: Siyaram ray

5. 10 Performance Enhancement Tips For Mobile App Development
Author: august sin

6. E-commerce Software Provider Company In India For Best E-commerce Solutions
Author: Zentryx Tech

7. Automation Testing - Selenium Webdriver Testing Tool
Author: Siyaram ray

8. Career Opportunities As A Selenium Tester
Author: Siyaram ray

9. How To Do A Good Job In Heatstroke Prevention In Chicken Farms
Author: How to do a good job in heatstroke prevention in c

10. Selenium Testing Tool Is More Used In Automation Testing
Author: Siyaram ray

11. Simplify For Better Sales: Tips For Optimizing The Checkout Page
Author: Shailesh Gajjar

12. Did Web Development Training Is Require
Author: Siyaram ray

13. Join Selenium Training In Bangalore To Become Selenium Master
Author: Siyaram ray

14. Direct Mail Marketing Services – Why It Is An Integral Part Of Your Advertising Campaign
Author: Daniel Mena

15. Building Advance Website On Drupal Cms – A Scalable Option For Your Business
Author: Zentryx Tech

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: