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.
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:
&driver.SetAttributeByID("BTN_FIRST", "class", "new-class")
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")
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")
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")
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")
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:
Example:
&onclickEvent = &driver.GetAttributeById("buttonX", "onclick")
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:
Example:
&onclickEvent = &driver.GetAttributeByName("buttonX", "onclick")
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:
Example:
&onclickEvent = &driver.GetAttributeByCSS("buttonCSSSelector", "onclick")
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:
Example:
&onclickEvent = &driver.GetAttributeByXPath("buttonXPath", "onclick")
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:
Example:
&link = &driver.GetAttributeByLinkText("Click here", "src")