Forum Discussion

KellyWiegand's avatar
KellyWiegand
Occasional Contributor
2 years ago

How to fill all the text box in page?

Hi,

Is there a way I can fill the entire page by script?

We have some pages that are similar, but have little difference such as pageA has 2 more textbox than pageB.

I don't know the specific difference for each page, but it's OK to just fill in any test data.

I used to use the Fake Data extension to fill the entire page, and I learned that it's workable to use selenium to ergodic every textbox.

Can I use script to make this? 

 

  • Here's an example that highlights all the objects where ObjectType equals Textbox,

    function Fields()
    {
        // https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_test
        var page = NameMapping.Sys.Browser("chrome").Page("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_test").Panel("container").Panel("iframecontainer");
        var fields = page.FindAll("ObjectType", "Textbox", 100);
        for (var i = 0; i < fields.length; i++) {
            Sys.HighlightObject(fields[i]);
        }
    }

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Here's an example that highlights all the objects where ObjectType equals Textbox,

    function Fields()
    {
        // https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_test
        var page = NameMapping.Sys.Browser("chrome").Page("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_test").Panel("container").Panel("iframecontainer");
        var fields = page.FindAll("ObjectType", "Textbox", 100);
        for (var i = 0; i < fields.length; i++) {
            Sys.HighlightObject(fields[i]);
        }
    }

     

    • KellyWiegand's avatar
      KellyWiegand
      Occasional Contributor

      rraghvani, 

      Thank you so much, this is exactly what I've been looking for!

  • eykxas's avatar
    eykxas
    Regular Contributor

    Through scripts, you can get all the textbox objects, then iterate it via a for loop and set each textbox.

    But I think set all the textbox at once is not possible (if it's the behavior of fake data extension).

    • KellyWiegand's avatar
      KellyWiegand
      Occasional Contributor

      Hi eykxas,

      Thank you for your reply, could you please tell me how to get all the textbox objects by scripts?

      Actually this brings another issue: by using the xpath, I can find the element in browser, but the TC script just can't locate it.