0

I have script in Groovy which is filling input fields in form in web app. It is working good but I have combobox where my script must

  1. Enter text from excel file - and it is working
  2. Click on span or div with text, which appears below input field after filling it - in other case when it clicks on next object the filled text disappear.

I want to have that kind of logic:

  1. If you find string - put the text in input
  2. But if you find combobox put the text in it and click on field which appears below, if it is span
  3. In other case when the field is div, click on div.

      //THIS VARIABLE WORKS OK

           Obiekt = WebUI.modifyObjectProperty(findTestObject('Empty/SENCHATEST_empty'), 'xpath', 'null', ('//div[@senchatest=\'' + 
           SENCHATEST) + '\']//input', true)
       
       //THIS TWO DO NOT WORK

       comboSpanClick = WebUI.modifyObjectProperty(findTestObject('Empty/span_empty'), 'xpath', 'null', ('//span[(text() = ' +
           fieldText) + ')]', true)
       
       comboDivClick = WebUI.modifyObjectProperty(findTestObject('Empty/div_empty'), 'xpath', 'null', ('//div[(text() = ' +
           fieldText) + ')]', true)
   
   //THIS PART IS WORKING (THERE ARE VARIABLES FROM EXCEL FILE)

       WebUI.waitForElementClickable(Obiekt, 10)
       if (fieldType == 'string') {
           WebUI.click(Obiekt)
           WebUI.setText(Obiekt, fieldText)
       }
       if (fieldType == 'number') {
           WebUI.click(Obiekt)
           WebUI.setText(Obiekt, fieldText)
       }
       if (fieldType == 'date') {
           WebUI.click(Obiekt)
           WebUI.setText(Obiekt, fieldText)
       }
       if (fieldType == 'combo') {
           WebUI.click(Obiekt)
           WebUI.setText(Obiekt, fieldText)
           
           WebUI.delay(2)
       }
   
   //AND THE SCRIPT STOPS WORKING HERE

           else if (WebUI.waitForElementClickable(comboSpanClick, 10))
           WebUI.click(comboSpanClick)
       
           elif (WebUI.waitForElementClickable(comboDivClick, 10)) { 
               WebUI.click(comboDivClick)
           }
matsi
  • 27
  • 5
  • I am not certain about your steps : 1. You are filling a input field (taking value from excel) and then once it's filled, we may have a span or div right ? – cruisepandey Jun 18 '21 at 10:28
  • After starting filling combobox the list with records from database appears. For example - months, when you enter "Ju", "Jun" and "July" appears below. I want my script to click on "July" and in my app it can be div or span and i want my script to recognize it and separate - if it is span, click on span, but if it is div, click on div – matsi Jun 18 '21 at 10:42
  • Show how the span and div looks in your html. Also provide fieldText value – daggett Jun 19 '21 at 03:43
  • @daggett Zbieranie potrzeb – matsi Jun 21 '21 at 13:56
  • you should quote text value for xpath: `'//div[(text() = "' + fieldText) + '" )]'` – daggett Jun 21 '21 at 14:01

0 Answers0