JetBrains / intellij-ui-test-robot

The library allows you to write and execute UI tests among IntelliJ IDEA. You can test your Plugin.
https://jetbrains-platform.slack.com/archives/C026SVA9MMM
Apache License 2.0
106 stars 31 forks source link

comboBox() from CommonContainerFixture does not work with @class='ComboBox' #112

Closed zcervink closed 2 years ago

zcervink commented 2 years ago

I have used the comboBox() successfully several times for "JComboBox" - comboBox(byXpath("//div[@class='JComboBox']"), Duration.ofSeconds(10));

When trying to implement it for custom pages in New Project wizard for "ComboBox", it does not work: comboBox(byXpath("//div[@class='ComboBox']"), Duration.ofSeconds(10)).selectItemContains(...........);

I have trie to change it, does not work too: comboBox(byXpath("//div[@class='JComboBox']"), Duration.ofSeconds(10)).selectItemContains(...........);

16:22:14 INFO : Search 'New Project Dialog' by 'MyDialog type'
16:22:14 INFO : Search 'Combobox' by '//div[@class='ComboBox']'
16:22:15 INFO : Select 'Maven'
16:22:15 INFO :     Select 'Maven'
16:22:45 WARN :         Failed on step: Select 'Maven' (StepWorker.kt_step)
16:22:45 WARN :     Failed on step: Select 'Maven' (StepWorker.kt_step)
Snímek obrazovky 2021-10-21 v 16 14 09
zcervink commented 2 years ago

Update: I tried to read the value from there, it is possible:

ComboBoxFixture comboBoxFixture = comboBox(byXpath("//div[@class='ComboBox']"), Duration.ofSeconds(10));
comboBoxFixture.selectedText()
zcervink commented 2 years ago

Update I made it working, it looks like it needs an extra click to make it work with some combo boxes:

        ComboBoxFixture comboBoxFixture = comboBox(byXpath("//div[@class='ComboBox']"), Duration.ofSeconds(10));
        if (!comboBoxFixture.selectedText().contains(buildTool.toString())) {
            comboBoxFixture.click();
            comboBoxFixture.selectItem(buildTool.toString());
        }

To be completely clear this issue appear in the intellij-quarkus extension in New Project creation wizard (custom page):

Snímek obrazovky 2021-10-21 v 18 56 32
nizienko commented 2 years ago

My suggestion is that items in combobox model load lazily after the first combobox menu open. So I think I'll add this click when the item is not found.

nizienko commented 2 years ago

additional click now supported in ComboBoxFixture

zcervink commented 2 years ago

@nizienko We should reopen this issue - I have tested the RR version 0.11.8 and the fix works only for the selectItemContains() method, not for the selectItem() method. If I run the click() before the selectItem(), everything is ok. Maybe the resolution to this issue would be move the newly added if from the selectItemContains() and replace the if in selectItem() (only one proper if would be sufficient because selectItemContains() calls selectItem() or selectItem() could be called directly).

Here is stacktrace:

timeout
java.net.SocketTimeoutException: timeout
    at okio.Okio$4.newTimeoutException(Okio.java:232)
    at okio.AsyncTimeout.exit(AsyncTimeout.java:286)
    at okio.AsyncTimeout$2.read(AsyncTimeout.java:241)
    at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:230)
    at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.java:242)
    at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.java:213)
    at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.java:115)
    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:94)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
    at okhttp3.RealCall.execute(RealCall.java:81)
    at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
    at com.intellij.remoterobot.client.IdeRobotClient.execute(IdeRobotClient.kt:63)
    at com.intellij.remoterobot.JavaScriptApi$DefaultImpls.runJs(JavaScriptApi.kt:57)
    at com.intellij.remoterobot.RemoteRobot.runJs(RemoteRobot.kt:32)
    at com.intellij.remoterobot.fixtures.Fixture.runJs(Fixture.kt:92)
    at com.intellij.remoterobot.fixtures.Fixture.runJs$default(Fixture.kt:85)
    at com.intellij.remoterobot.fixtures.ComboBoxFixture$selectItem$1.invoke(ComboBoxFixture.kt:38)
    at com.intellij.remoterobot.fixtures.ComboBoxFixture$selectItem$1.invoke(ComboBoxFixture.kt:34)
    at com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step(StepWorker.kt:23)
    at com.intellij.remoterobot.fixtures.ComboBoxFixture.selectItem(ComboBoxFixture.kt:34)
olkornii commented 3 months ago

@nizienko I can confirm that this fix does not work for "selectItem(...)". Workaround still required.