0

I just wrote some code to open IRCTC website. After this I would like to login but how can I get xpath? Also, is there any possibility to automate captcha?

public void login() {
  driver = new FirefoxDriver();
  driver.manage().window().maximize();
  driver.get("https://www.irctc.co.in/eticketing/loginHome.jsf");
}
Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
  • Where is your code..and what is beautifulSoup working for you? – therealprashant Jan 04 '16 at 06:03
  • You can't do right click because it is behaviour of that website. You can't change the behaviour of website using selenium while you can try some javascript to enable it . There is no way to read capcha using selenium – Shubham Jain Jan 04 '16 at 06:41

3 Answers3

1

I just wrote some code to open an IRCTC website. After this I would like to login but how can I get xpath?

To get an xpath you can just look at the source code. Ctrl + U in chrome shows source code or you can open developer console - ctrl+shft+j , for example the xpath for the user name field is //*[@id="usernameId"]

Please refer to the screenshot. I have used developer console. it opens when you click ctrl+shft+j

enter image description here

Shamik
  • 1,591
  • 2
  • 16
  • 36
  • Thanks alot.. Mr.Shamik and what about captcha do you hav any idea – Siva Rama Krishna Jan 04 '16 at 11:51
  • Well if you are ready to pay use the above answer.. but captcha is meant to deter any automation so I personally do not think anything will work that well to automate, you are not supposed to go past captcha using any automated tool, thats how it is designed . By the way please accept this as answer if it has helped. Thanks! – Shamik Jan 04 '16 at 12:11
0

CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart (wiki) and its main purpose is to provide a challenge-response scenario to make automated scripts fail.

There are two options to solve this problem:

1) Working with development team to disable CAPTCHA for test builds so that your automation scripts work. (Since you are trying on IRCTC public website, you cannot do that)

2) Or use third-party services (paid) such as DeathByCaptcha which uses OCR and other techniques to find the CAPTCHA code. The website says it takes an average of 1 min to find the CAPTCHA of the image supplied with ~94% accuracy.

Another SO post discussing about this and another blog post on API details.

Community
  • 1
  • 1
parishodak
  • 4,506
  • 4
  • 34
  • 48
0

If you need to inspect the element using the firebug or firepath then press F12 key in the firefox. Then it opens up the inspector, click on firepath tab and inspect the element. You get the absolute path.

Pradeep
  • 1
  • 4