codeforequity-at / botium-core

The Selenium for Chatbots - Bots Testing Bots
https://www.botium.ai
MIT License
231 stars 64 forks source link

OPENBOT custom script does not work #454

Closed xmichele closed 4 years ago

xmichele commented 4 years ago

Dear team,

under the new version of botium my old custom openbot script doesn't work. I suspect that is related to botium-connector-webdriverio 0.2.0 update. I tried to follow the examples such as snippets/openbot.js but with no good results . Basically I set 2 text field and then I click on login, js file: module.exports = (container, browser) => { return browser .waitForVisible('#username', 20000).then().setValue('#username', 'myuser') .waitForVisible('#password', 5000).then().setValue('#password', 'mypsdw') .waitForVisible('#kc-login', 5000).then().click('#kc-login') .pause(1000) }

WebDriver error on startup: TypeError: browser.waitForVisible is not a function -> I tried with waitForDisplayed

codeforequity-at commented 4 years ago

You are right, there is a breaking change as we switched to webdriverio version 5, we documented this in the repository: https://github.com/codeforequity-at/botium-connector-webdriverio

You can use the old connector version with webdriver 4 furthermore, but we won´t work on it in future. webdriver 5 has lots of advantages (for example support for shadow dom).

xmichele commented 4 years ago

Sorry for my basic understanding of js and node. I tried in these ways to be compatible with the new version but nope: 1) module.exports = (container, browser) => { return browser .then(() => browser.$('#username').then(uname => uname.waitForDisplayed(20000).setValue('myuser'))) .then(() => browser.$('#password').then(psw => psw.waitForDisplayed(5000).setValue('mypsw'))) .then(() => browser.$('#kc-login').then(ccBtn => ccBtn.waitForDisplayed(5000).then(() => ccBtn.click())) .then(() => browser.pause(2000)) }

2) module.exports = async (container, browser) => { const ccUser = await browser.$('#username') await ccUser.waitForDisplayed(20000) await ccUser.setValue('#username', 'myuser')

const ccPsw = await browser.$('#password') await ccPsw.waitForDisplayed(5000) await ccPsw.setValue('#password', 'mypsw')

const ccBtn = await browser.$('.kc-login') await ccBtn.waitForDisplayed(5000) await ccBtn.click() console.log('cc-btn clicked')

await browser.pause(1000) }

xmichele commented 4 years ago

With procedure 2. seemed to work for the custom pre-conversation part. But for the same old convo I was using succesfully with old version , now it retries to ping the output element .. WEBDRIVERIO_OUTPUT_ELEMENT //div[@class='chat-content']/div[@class='chatbot-chat']/div[@class='message']

Is something changed for the xpath expressions as well?

codeforequity-at commented 4 years ago

afaik, the xpath expressions are the same - in our tests, we had to rewrite the javascript snippets to adapt to the new webdriver API, but everything else we didn't have to touch. But i would not take a bet that there are additional incompatibilities. what is the output shown ?

xmichele commented 4 years ago

0-01-15T11:32:18.579Z INFO webdriver: RESULT true 2020-01-15T11:32:18.580Z INFO webdriver: COMMAND elementClick("e3fcc924-525e-4b4b-99d6-e85ac5484855") 2020-01-15T11:32:18.580Z INFO webdriver: [POST] http://selenium:4444/wd/hub/session/83c5eeb70930979a888a8f82c0e88619/element/e3fcc924-525e-4b4b-99d6-e85ac5484855/click cc-btn clicked botium-connector-webdriverio Waiting for 1 welcome messages (will be ignored) ... +2s botium-connector-webdriverio polling for bot output (//div[@class='chat-content']/div[@class='chatbot-chat']/div[@class='message'], currentCount: 0 +0ms 2020-01-15T11:32:19.923Z INFO webdriver: COMMAND findElements("xpath", "//div[@class='chat-content']/div[@class='chatbot-chat']/div[@class='message']") 2020-01-15T11:32:19.924Z INFO webdriver: [POST] http://selenium:4444/wd/hub/session/83c5eeb70930979a888a8f82c0e88619/elements 2020-01-15T11:32:19.925Z INFO webdriver: DATA { using: 'xpath', value: "//div[@class='chat-content']/div[@class='chatbot-chat']/div[@class='message']" } 2020-01-15T11:32:19.962Z INFO webdriver: RESULT [] 2020-01-15T11:32:20.424Z INFO webdriver: COMMAND findElements("xpath", "//div[@class='chat-content']/div[@class='chatbot-chat']/div[@class='message']") 2020-01-15T11:32:20.424Z INFO webdriver: [POST] http://selenium:4444/wd/hub/session/83c5eeb70930979a888a8f82c0e88619/elements 2020-01-15T11:32:20.424Z INFO webdriver: DATA { using: 'xpath', value:

codeforequity-at commented 4 years ago

Is the website hosting this bot available to public so I can try myself ?

xmichele commented 4 years ago

Unfortunatly not! But I used the same conf file

codeforequity-at commented 4 years ago

Just a shot into the dark, but does it make difference wether you use @Class or @class in the expressions ? (capitals) or maybe use this instead:

//div[contains(@class,'chat-content')]
xmichele commented 4 years ago

tried but same result and also for the input as well: "WEBDRIVERIO_INPUT_ELEMENT":"//*[contains(@id,'myInput')]",

xmichele commented 4 years ago

Hello, I attached my setup with docker as well. If you can please give a look

E2E_tester.zip

codeforequity-at commented 4 years ago

hi, i did not forget it, but didn't have time yet. will get back on you.

Am Mo., 20. Jan. 2020 um 16:03 Uhr schrieb xmichele < notifications@github.com>:

Hello, I attached my setup with docker as well. If you can please give a look

E2E_tester.zip https://github.com/codeforequity-at/botium-core/files/4086757/E2E_tester.zip

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/codeforequity-at/botium-core/issues/454?email_source=notifications&email_token=AGIR2T4NMW7KJCQOY5SRNA3Q6W4LVA5CNFSM4KGQJEI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJM5NSA#issuecomment-576313032, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGIR2T5SSDTXSMZAUOTKVS3Q6W4LVANCNFSM4KGQJEIQ .

--

Florian Treml, Bacc. Techn. Founder and Lead Developer

Botium GmbH

Gerasdorfer Straße 141/8, A-1210 Wien Mail: florian.treml@botium.at Blog: https://medium.com/@floriantreml Github: https://github.com/codeforequity-at/botium-core

Botium GmbH registriert beim Handelsgericht Wien unter FN 486747f Geschäftsführer: Christoph Börner UID: ATU73085118

xmichele commented 4 years ago

Yes, thanks.. still blocked :(

codeforequity-at commented 4 years ago

The docker-compose doesn't work, because it is missing a file (ClaraLogin.js), but this won't help much if I don't have access to the chatbot sources.

I did some small fixes to the Botium webdriver connector (https://github.com/codeforequity-at/botium-connector-webdriverio/pull/11), but I don't think they will help in your case. I made the sample (https://github.com/codeforequity-at/botium-connector-webdriverio/tree/features/Webdriver-Debug/samples/custom) work with XPath, and I had no trouble.

Does it make a difference in your case if you replace the @class=... with contains(@class, ...) in your XPath selectors ? I would recommend to use a tool like ChroPath for checking the selectors.

"WEBDRIVERIO_OUTPUT_ELEMENT": "//div[@class='chat-content']/div[@class='chatbot-chat']/div[@class='message']",

use this instead:

"WEBDRIVERIO_OUTPUT_ELEMENT": "//div[contains(@class, 'chat-content')]/div[contains(@class, 'chatbot-chat')]/div[contains(@class, 'message')]",
xmichele commented 4 years ago

Fixed ClaraLogin.js but I was trying also skipping openbot authentication. For synthax like this : div[contains(@class, 'chat-content')] I have tried but nope. I will try with new codeforequity-at/botium-connector-webdriverio if already available

codeforequity-at commented 4 years ago

i think i cannot help further without seeing whats actually going on. i can offer to sign an nda so we could access the bot for development purposes.

codeforequity-at commented 4 years ago

?

codeforequity-at commented 4 years ago

have you been able to make this work ?

xmichele commented 4 years ago

sorry for the late, the procedure is quite long and I was moved in the meantime on another project. So if I'll be reassigned and able to fix I'll update you. Thanks

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.