0

I am currently working on automation project.Scripts are written in selenium and java language.Actually my question is an RnD type. Because we can find elements in selenium giving element id or xpath or etc... driver.find_element_by_id('loginForm')but the problem is that we cant actually know that what we given element path is correct or wrong until script execute in web driver.So my question is that is it possible to develop some kind of plugin that will tell you when you write some code snippt on IDE and it will tell you that element is available or unavailable with out execution a script on web driver.

eg: let say i type this code snippt on eclipse driver.find_element_by_id('loginForm') and then eclipse IDE it mark as a error if that element is can not find without execute the script.

Please guys let me know your ideas to get an idea to develop a such kind of thing and if you already know that kind of plugin please share with me.

gihan-maduranga
  • 4,381
  • 5
  • 41
  • 74
  • 1
    I think it is not possible to check that a selector is valid or not without running any script. – peetya Jun 30 '15 at 16:18

1 Answers1

0

You can use the developer tools available on all modern popular browsers to check if you got the selector correct.

  • On Firefox click on Tools -> Web Developer -> Web Console.
  • On Chrome click on View -> Developer -> JavaScript Console

Once on that you can use javascript or jquery to check your css selector.

In Javascript

document.getElementById() // By Id
document.getElementsByClassName() // By Class Name
document.getElementsByName() // By Name
document.getElementsByTagName() // By Tag Name
document.querySelector() // By CSS Selector

You can also use third party plugins, example - Firebug for firefox. To make things easier there are plugins on top of Firebug as well : Firepath and Firefinder for Firebug

Amey
  • 8,470
  • 9
  • 44
  • 63
  • yes i can use that way too.But i want something like check the selector in eclipse compile time with out execute script.Becasue executing script something like wasting time.so if there is a error on selector i have to execute same script multiple time to check it.rather than if i can find in compile time and give an error it would be good and can save time. – gihan-maduranga Jul 01 '15 at 12:55