Table of contents

Contents



Official Content

These commands are useful to modify and retrieve specific element attributes such as class, style, or any other. It requires the element selector and the name of the attribute to get or set its value.

SetAttributeByID

SetAttributeByID_png

Sets a new value for an attribute of an element by its ID attribute value. If the attribute is not present, it is created.

Parameters:

  • ID: element ID 
  • Attribute: name of the attribute to set
  • Value: value to set

Example:

Suppose the gx-button element:
GetAtrribute-Example_png

&driver.SetAttributeByID("BTN_FIRST", "class", "new-class")

SetAttributeByName

SetAttributeByName_png

Sets a new value for an attribute of an element by its name attribute value. If the attribute is not present, it is created.

Parameters:

  • Name: element's name attribute value
  • Attribute: name of the attribute to set
  • Value: value to set

Example:

&driver.SetAttributeByName("elemName", "attrName", "newValue")

SetAttributeByCSS

SetAttributeByCSS_png

Sets a new value for an attribute of an element by CSS selector. If the attribute is not present, it is created.

Parameters:

  • CSS: element CSS selector
  • Attribute: name of the attribute to set
  • Value: value to set

Example:

&driver.SetAttributeByCSS("cssSelector", "attrName", "newValue")

SetAttributeByXPath

SetAttributeByXPath_png

Sets a new value for an attribute of an element by an XPath selector. If the attribute is not present, it is created.

Parameters:

  • XPath: element XPath selector
  • Attribute: name of the attribute to set
  • Value: value to set

Example:

&driver.SetAttributeByXPath("xpathSelector", "attrName", "newValue")

SetAttributeByLinkText

SetAttributeByLinkText_png

Sets a new value for an attribute of an element by its link text. If the attribute is not present, it is created.

Parameters:

  • LinkText: element link text
  • Attribute: name of the attribute to set
  • Value: value to set

Example:

&driver.SetAttributeByLinkText("link text", "attrName", "newValue")

GetAttributeByID

GetAttributeByID_png

Gets the value of the attribute of an element by its ID.

Parameters:

  • ID: element ID 
  • Attribute: name of the attribute to get its value

Returns:

  • Attribute's value

Example: 

&onclickEvent = &driver.GetAttributeById("buttonX", "onclick")

GetAttributeByName

GetAttributeByName_png

Gets the value of the attribute of an element by its ID

Parameters:

  • Name: element name
  • Attribute: name of the attribute to get its value

 Returns:

  • Attribute's value

Example: 

&onclickEvent = &driver.GetAttributeByName("buttonX", "onclick")

GetAttributeByCSS

GetAttributeByCSS_png

Gets the value of the attribute of an element by a CSS selector

Parameters:

  • CSS: element CSS selector 
  • Attribute: name of the attribute to get its value

 Returns:

  • Attribute's value

Example: 

&onclickEvent = &driver.GetAttributeByCSS("buttonCSSSelector", "onclick")

GetAttributeByXPath

GetAttributeByXPath_png

Gets the value of the attribute of an element by XPath

Parameters:

  • XPath: element XPath selector
  • Attribute: name of the attribute to get its value

 Returns:

  • Attribute's value

Example: 

&onclickEvent = &driver.GetAttributeByXPath("buttonXPath", "onclick")

GetAttributeByLinkText

GetAttributeByLinkText_png

Gets the value of the attribute of an element by its link text

Parameters:

  • LinkText: element's link text 
  • Attribute: name of the attribute to get its value

 Returns:

  • Attribute's value

Example: 

&link = &driver.GetAttributeByLinkText("Click here", "src")

 


Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant