Chaoui05 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks !! I have this following issue: i would like to get 2 input from my web page.But i have the same xpath for both. I used for that Developper Tools. I can get the first but not the second. And i wrote that in my code :

for first:

$elem = $driver->find_element('//input[1][@class="dx-texteditor-input"]')->send_keys("Live");

for second:

$elem = $driver->find_element('//input[2][@class="dx-texteditor-input"]')->send_keys("Live");

And with Inspector chrome,i have thoses xpath :

First:

//*[@id="parameters"]/div/div[4]/div[2]/div/input

Second:

//*[@id="program_logs"]/div/div[4]/div[2]/div/input

I Think i have to use 'id' but i don't know how

Thanks !!

Replies are listed 'Best First'.
Re: Xpath with Selenium
by Corion (Patriarch) on Apr 28, 2016 at 12:28 UTC

    Your question is not a Perl question but an XPath question.

    Why can't you use the XPath queries that the Chrome Inspector gives you?

      Iam not sure that's a xpath question only. Cause iam using it in Selenium Perl test context. Rightly i used xpath from Chrome Inspector but iam not sure , i think it's different with :
      $elem = $driver->find_element('//input[1][@class="dx-texteditor-inpu +t"]')->send_keys("Live");
      Previous above works but not second as i told.

        You are using some XPath queries that are different from what you show that Chrome Inspector shows as the XPath queries.

        This is still an XPath question, but you are using the wrong XPath queries.

        I don't know how to help you further except to repeat that you need to use what Chrome Inspector shows you instead of making up random stuff.