como obter o xpath de testObject de Katalon estúdio em arquivo jar 3rd party

user3302083:

Eu quero criar arquivo jar 3o partido para a funcionalidade "personaliza espera", que vai ainda mais o uso em Katalon Casos estúdio de teste para sincronizar o caso de teste chamando "waitTillObjectPresent ()".

Amostra da minha função de chamada de Katalon Estúdio seria como a seguir:
Aqui eu estou tentando função de chamada java "waitTillObjectPresent ()" do Katalon Studio.

  WebUI.navigateToUrl('https://www.companysite.com/en')
//Wait for element till present upto 10 sec.
        WaitForObject.waitTillObjectPresent'(findTestObject('V3-Web/WaitForObject/Page_Livtten/button_Results'), 10)
        WebUI.click(findTestObject('V3-Web/WaitForObjectDemo/Pagetten/button_Results'))

Nota: No código acima "WaitForObject" é o meu Java Class e "waitTillObjectPresent" é o método espera fluente em mesma classe.

Tentei com seguinte código java:

public void waitTillObjectPresent(TestObject to, int waitingtime){
// HERE IS ISSUE, I am not getting TestObject from Katalon Studio calling method 

   int counter=0;
   String locator= object.findPropertyValue('xpath');

    System.out.println("xpath is:: " + locator);
    WebDriver driver = DriverFactory.getWebDriver();
  // HERE IS ISSUE, I am not able to getting  WebDriver instance from Katalon Studio 

    // fluent wait method 
            Wait wait = new FluentWait(driver )
            .withTimeout(waitingtime, TimeUnit.SECONDS)
            .pollingEvery(1000, TimeUnit.MILLISECONDS)
            .ignoring(WebElementNotFoundException.class)

            WebElement ele = (WebElement) wait.until(new Function<WebDriver, WebElement>()  {
                public WebElement apply(WebDriver driver) {
                    counter ++
                    return driver.findElement(By.xpath(locator));
                }
            });
    System.out.println("Waiting time for Object ::: "+ object+" ::: rendering is :::: " +counter*700 +"  ::: miliseconds ie in seconds ::: " +(counter*700)/1000);
    }
}

No código acima estou recebendo erros em 2 pontos:

1ª EDIÇÃO: eu não estou recebendo o TestObject no programa java a partir Katalon estúdio.

2ª EDIÇÃO: eu não sou capaz de conseguir a instância Webdriver com o código WebDriver driver = DriverFactory.getWebDriver();

ajuda gentilmente me Eu sou novo para Katalon estúdio.

user1999758:

Aqui é a melhor solução:

1ª EDIÇÃO: eu não estou recebendo o TestObject no programa java a partir Katalon estúdio.

Para o problema acima, você não pode cobrar o valor do objeto como este String locator= object.findPropertyValue('xpath');que você precisa fazer algo parecido com isso para obter os valores de objeto

public static String  getFieldNamesAndValues(final Object obj, boolean publicOnly)
            throws IllegalArgumentException, IllegalAccessException {
        Class<? extends Object> c1 = obj.getClass();
        System.out.println("Class value is c1:::" + c1);
        Map<String, Object> map = new HashMap<String, Object>();
        Field[] fields = c1.getDeclaredFields();
        System.out.println("Fields in objects :: " + fields.toString());
        System.out.println("Xpath Before for loop::: " + fields.getClass());
        for (int i = 0; i < fields.length; i++) {
            String name = fields[i].getName();
            System.out.println("Fields name ::: " + name);
            if (publicOnly) {
                if (Modifier.isPublic(fields[i].getModifiers())) {
                    Object value = fields[i].get(obj);
                    map.put(name, value);
                }
            } else {
                fields[i].setAccessible(true);
                Object value = fields[i].get(obj);
                map.put(name, value);
            }
        }
        System.out.println("Return on object is ::::--> " + map.get("selectorCollection").toString());
        return (String) map.get("selectorCollection");
    }

E chamar o programa acima getFieldNamesAndValues(Testobject, false), em vez de fazer issoString locator= object.findPropertyValue('xpath');

2ª EDIÇÃO: eu não sou capaz de conseguir a instância Webdriver com o motorista WebDriver code = DriverFactory.getWebDriver ();

Para a 2ª emissão: passar a instância DriverFactory.getWebDriver () de Katalon estúdio para java como este

//Wait for element till present upto 10 sec.
        WaitForObject.waitTillObjectPresent'(DriverFactory.getWebDriver() , findTestObject('V3-Web/WaitForObject/Page_Livtten/button_Results'), 10)

Acho que você gosta

Origin http://43.154.161.224:23101/article/api/json?id=331050&siteId=1
Recomendado
Clasificación