Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
5 years ago
Solved

QuerySelector

Hi,

I'm new to this feature, I would like to identify an object to use the "SetText()" or "Key()" method on it.

 

Could Someone tell me what should I write in CSSSelector to identify this object ?

(The identifier is "sMatricule")

 

Thank you !

 

  • I finally found it :

     

    Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('test');

  • Hi,

     

    a) Robert is correct with his note. Any reason not to use Aliases.browser.page ?

    b) Exactly as I said (without knowing your tested application details) - button click reloads the page, but your code does not wait for page to load and looks for the object. As the object does not exist yet, the search fails.

    At least, I would recommend to execute

    Aliases.browser.page.Wait()

    after the click to wait for the page to load. Depending on your tested application, additional delays might be required to wait for page scripts and relevant Ajax calls to complete.

     

10 Replies

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    I finally found it :

     

    Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('test');

    • m_essaid's avatar
      m_essaid
      Valued Contributor

      Hi,

      I don't understand something :

      I write my script with the following code :

       

      Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('00052');

       

      And when I close the browser, re-open it I try to replay the script it says "Undeclared identifier: SetText".

       

      Anyone has an idea ?

       

      Thanks,

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        "Undeclared identifier: SetText"

        This means that the sought for object (.QuerySelector('[data-bind="value: sMatricule"]')) was not found, .QuerySelector() returned null and thus runtime engine failed to reference the SetText identifier.