Skip to content

sofiasyria/libyui_client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibyuiClient

Ruby gem to interact with YaST applications via libyui-rest-api.

Usage example:

require 'libyui_client'

app = LibyuiClient::App.new(host: 'localhost', port: '9999')
button = app.button(id: 'settime')
button.click

Installing libyui_client

As soon as the gem is in development, run the following command from command line:

gem "libyui_client", :git => "git@github.com:jknphy/libyui_client.git"

Now need to require gem in order to use it.

Initialize the app under control

It is assumed the application is running on localhost:9999. Then the code to initialize the application looks like:

require 'libyui_client'

app = LibyuiClient::App.new(host: 'localhost', port: '9999')

Supported widgets

libyui_client supports different types of widgets.

Here are examples of usage:

Button

app.button(id: 'test_id').click  # clicks the button with id 'test_id'
app.button(label: 'test_label').debug_label # get 'debug_label' value with label 'test_label'

Checkbox

app.checkbox(id: 'test_id').check  # checks the checkbox with id 'test_id'
app.checkbox(label: 'test_label').checked? # gets the state of checkbox with label 'test_label'
app.checkbox(id: 'test_id').toggle # toggles the checkbox with id 'test_id'
app.checkbox(id: 'test_id').uncheck  # unchecks the checkbox with id 'test_id'

Combobox

app.combobox(id: 'test_id').items  # gets all available items for combobox with id 'test_id'
app.combobox(id: 'test_id').select  # selects the checkbox with id 'test_id'
app.combobox(id: 'test_id').selected_item # gets the selected item in combobox with id 'test_id'

Label

app.label(id: 'test_id').heading?  # gets if label has bold font respresentation with id 'test_id'
app.label(id: 'test_id').text  # gets text from label with id 'test_id'

Menubutton

app.menubutton(id: 'test_id').click('button1')  # clicks on 'button1' of menubutton with id 'test_id'

Numberbox

app.numberbox(id: 'test_id').min_value  # gets min value to be set in numberbox with id 'test_id'
app.numberbox(id: 'test_id').max_value  # gets max value to be set in numberbox with id 'test_id'
app.numberbox(id: 'test_id').set(99)  # sets 99 to numberbox with id 'test_id'
app.numberbox(id: 'test_id').value  # gets value from numberbox with id 'test_id'

Radiobutton

app.radiobutton(id: 'test_id').select  # selects the radiobutton with id 'test_id'
app.radiobutton(id: 'test_id').selected?  # gets the state of radiobutton with id 'test_id'

Richtext

app.richtext(id: 'test_id').click_link('test_link')  # clicks on link "test_link" with id 'test_id'
app.richtext(id: 'test_id').text  # gets text from richtext

Tab

app.tab(id: 'test_id').items  # gets items from tab with id 'test_id'
app.tab(id: 'test_id').select(value: 'item')  # selects specific tab with id 'test_id'
app.tab(id: 'test_id').selected_item  # gets selected tab for tab with id 'test_id'

Table

app.table(id: 'test_id').empty? # checks if there is not rows in table with id 'test_id'
app.table(id: 'test_id').items  # gets rows in the table with id 'test_id'
app.table(id: 'test_id').select(value: 'test.item.1', # selects row in table with value test.item.1
                                column: 'test.header')  # and column test.header
app.table(id: 'test_id').seleted_items # gets items currently selected in table with id 'test_id'

Textbox

app.textbox(id: 'test_id').max_length
app.textbox(id: 'test_id').set('Test Text')  # sets "Test Text" to textbox with id 'test_id'
app.textbox(id: 'test_id').password? # checks password mode for textbox with id 'test_id'
app.textbox(id: 'test_id').valid_chars # checks valid chars for textbox with id 'test_id'
app.textbox(id: 'test_id').value  # gets value from textbox with id 'test_id'

Tree

app.tree(id: 'test_id').items  # gets items from tree with id 'test_id'
app.tree(id: 'test_id').select('node1|node1_2')  # selects item in tree with id 'test_id'
app.tree(id: 'test_id').selected_item  # gets currently highlighted item from tree with id 'test_id'

Filters

libyui_client supports the same filters, as libyui-rest-api provides:

  • id - widget ID serialized as string, might include special characters like backtick (`)
  • label - widget label as currently displayed (i.e. translated!)
  • type - widget class

Waits

Default timeout and interval

All the actions against widgets in libyui_client are made with default timeout and interval. Default timeout is 5 sec, default interval is 0.5 sec. That means libyui_client will repeat sending requests to YaST application every 0.5 seconds until 5 seconds timeout will be reached. This default wait is needed because widgets may not be loaded immediately while trying to interact with them (e.g. when navigating from one screen to another).

The default timeout and interval can be changed by the following:

LibyuiClient.timeout = 10
LibyuiClient.interval = 1

Specific waits

All the widgets include Waitable module, which contains special methods to allow explicit waiting: wait_until and wait_while. These methods can be used when it is needed to wait until some property of the widget will be changed.

For example, wait until button will be enabled and click on it:

# with #to_proc syntax:
app.button(id: 'test_id').wait_until(&:enabled?).click

# without #to_proc syntax:
app.button(id: 'test_id').wait_until{ |button| button.enabled? }.click

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 99.9%
  • Shell 0.1%