Skip to content

Final Weeks Of SoK23 With KDE Eco: Writing Scripts In Selenium To Reproduce KdeEcoTest Script

Thursday, 20 April 2023 | Nitin Tejuja


Thank you once again to the KDE community for having me as part of this amazing Free & Open Source project through their annual program Season of KDE (SoK). Please see this and this blog post for background information about the work described here.

Final Weeks Of SoK23

In these final weeks of SoK23 I have reproduced in Selenium the entire KdeEcoTestGcomprisScript.txt script, which emulates user behavior in different GCompris activities.

Video: Replication of KdeEcoTest script for GCompris. (Video from Nitin Tejuja published under a CC-BY-SA-4.0 license.)

After first understanding the original script written with the emulation tool KdeEcoTest (see this blog post also from an SoK23 mentee for recent updates to the tool), I began working on the activity called "Baby Word Processor". The GCompris website has screenshots and descriptions of this and other activities.

The "Baby Word Processor" activity includes a simple word processor which provides children the ability to easily write their first texts. The activity allows for saving, deleting, and loading text files.

I started by modifying the activity QML Code of "Baby Word Processor". I have added Accessible code to the Load and Save buttons in the activity. Below you can find the modified QML code in order to in order to be able to save text and reload them later on:

 GCButton {
    id: loadButton
    textSize: "regular"
    width: parent.width
    Accessible.name: "Load the file"
    text: qsTr("Load")
    onClicked: {
        keyboard.hide = true;
        creationHandler.loadWindow();
    }
    }
GCButton {
    id: saveButton
    textSize: "regular"
    Accessible.name: "Save the text to file`"
    width: parent.width
    text: qsTr("Save")
    onClicked: {
        keyboard.hide = true;
        var textToSave = {};
        // Remove focus to force text storing within the TextEdit
        edit.focus = false;
        textToSave["text"] = edit.getFormattedText(0, edit.length);
        creationHandler.saveWindow(textToSave);
    }
    }

Accessible code for this activity can be found here. With these modification to the QML Code, I wrote a Selenium script to test the activity, and code can be found here.

Once the above script was running, I worked on the KdeEcoTest scenario that modifies the volume configuration of GCompris. The volume settings are changed by clicking the configuration icon once the app has loaded. To modify the settings, I added Accessible code to Configuration QML elements. Accessible code can be found here.

I then wrote the Selenium script to modify the volume settings. Here, I had to learn how to perform scrolling on an element using Selenium. The problem was that the volume settings are located one scroll down in the Configuration window. The following example therefore performs one scroll down on an element.

 self.driver.find_element(by=AppiumBy.NAME, value="element_name").send_keys(
            Keys.DOWN
)

In GCompris's configuration, the volume settings are changed using a slider. Since selenium-webdriver-at-spi driver is in development, changing a slider value had not yet been implemented. So I made a request to Harald Sitter and he quickly updated the selenium-webdriver. I have now updated the driver and it works :)

The Selenium script for changing volume settings can be found here.

Finally, I was able to replicate all scenarios present in the GCompris KdeEcoTest emulation script using Selenium and I even added logs for actions taken in a format compatible with the data analysis tool OSCAR (Open source Software Consumption Analysis and Reporting).

Logs for actions taken in the Selenium script in a format compatible with <code>OSCAR</code>. (Image from Nitin Tejuja published under a <a href="https://spdx.org/licenses/CC-BY-SA-4.0.html">CC-BY-SA-4.0</a> license.)
Figure : Logs for actions taken in the Selenium script in a format compatible with OSCAR. (Image from Nitin Tejuja published under a CC-BY-SA-4.0 license.)

Community Bonding (SoK’23)

I want to thank everybody who made Season of KDE possible, especially my mentors.

I am very thankful to Harald Sitter for enhancing selenium-webdriver-at-spi whenever I encountered a problem that required a new functionality.

I am also thankful to you for taking the time to read this update. If you want to access the scripts, they can be found here.

Please feel free to contact me on Matrix at @nitin.tejuja12:matrix.org.


Article contributed by under the CC-BY-SA-4.0 license.