mardi 24 avril 2018

Why I can't find my textbox in a table and the setText() method is not correct

I'm using katalon studio to find a textbox in a table,firstly I loop in row (i)and then column(j) to tag the text box as 'input' based on the reference'AUTO_PO_11' in the same row.but when I run the scipt ,system prompts error below.

Error in log view:

Test Cases/SF 18093/Financial/FinReq FAILED because (of) org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"tagname","selector":"input"} (Session info: chrome=65.0.3325.181) (Driver info: chromedriver=2.38.551601 (edb21f07fc70e9027c746edd3201443e011a61ed),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z' System info: host: 'SGA1014', ip: '172.27.35.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102' Driver info: com.kms.katalon.selenium.driver.CChromeDriver Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.38.551601 (edb21f07fc70e9..., userDataDir: C:\Users\lixinyu\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 65.0.3325.181, webStorageEnabled: true} Session ID: fbc5f2874c0cedf234e7d9c560433c7a *** Element info: {Using=tag name, value=input}

my script for looping the table (find the row besed on the reference on the same row):

String ecpectedValue = 'AUTO_PO_11'

println(' Expected Value is ' + ecpectedValue)

WebDriver driver = DriverFactory.getWebDriver()

WebElementTable = driver.findElement(By.xpath('//*[@id="gview_inputGrid-grid"]/div[3]'))

Thread.sleep(6)

ListRows = Table.findElements(By.tagName('tr'))

found = false

KeywordLoggerlog = newKeywordLogger()

table: for (inti = 0; i

List<WebElement>Cols = Rows.get(i).findElements(By.tagName('td'))

for (intj = 0; j<Cols.size(); j++) {
    log.logInfo('**********' + Cols.get(j).getText()+ j)

    if (Cols.get(j).getText().equalsIgnoreCase(ecpectedValue)) {

        log.logInfo(('Im in column No.========' + Cols.get(j).getText()) +'========' +j)

        WebElementtags = Cols.get(j + 6).findElement(By.tagName('input'))

        log.logInfo((('gettext=======' + tags.getTagName()) + ' | ') + tags.getAttribute('href'))

        WebUI.setText(tags, '1')

        found = true

        Thread.sleep(10)

        break
    }

    if (found) {
        break
    }
}

if (found) {
    break
}

}

GUI table: enter image description here

Aucun commentaire:

Enregistrer un commentaire