Forum Discussion

william_roe's avatar
william_roe
Super Contributor
10 years ago
Solved

DevExpress 15 and Click Event on Radio Controls

We are upgrading to DevExpress 15 (from 14) and experiencing difficulties with using XPath and radio controls. Specifically, once the control is found there doesn't appear to be a click event.  I see that the className contain unchecked. How do I click on a radio button in DevX 15? Does it require SmartBear support?

 

 

function SelectSiteAccess() {
	// retrieves reference to browser
    var page = Aliases.browser.CribMaster.PrimaryWrapper.PrimaryContent.EmployeeGrid.sectionActionwrapper.sectionActioncontent.panel.tableSplresizing.cell2.panelSplresizing1Cc.formMainform.panelPnlgridpropertiescallback.panelPartialproperties.panelPartialpropertiesCc.Panel("partialProperties_C11").Panel(0).Article(0).Panel(0);

	if (Project.Variables.Employees.Value("SiteAccess") == null) { return; }

	// retrieves value from 'SiteAccess' column in spreadsheet
	var SiteAccess = Project.Variables.Employees.Value("SiteAccess").split(",");
	var AccessType = Project.Variables.Employees.Value("AccessType").split(",");

	// iterates through array of Site Access(s) and selects radio control
	for (var i = 0; i < SiteAccess.length; i++) {
		var obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//input[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S']", true);

		if (obj != null) {
			// clicks radio button
			try {
				obj.Click(); <====== FAILING HERE

			} catch (e) {
				Log.Error("Error clicking item!");
			}
		}
		else {
			Log.Error("Could not locate Access '" + AccessType[i] + "'" + " for Site '" + SiteAccess[i] + "'");
		}
	}
}

11 Replies

  • Hi William_roe,

     

    According to this line:

    var obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//input[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S']", true);

    you are getting all input elements with id=SiteAcces<Number>_<Number>_S.

    However, according to your screenshot, your page displays this element by using the span tag. So, I suggest that you change input with span in your test:

    var obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//span[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S']", true);

     

     

    • william_roe's avatar
      william_roe
      Super Contributor

      I noticed also the control type changed from input to span. However, if I change it to span the 'Click' event is still not found.. I've also tried changed setting the  'page' variable to "Sys.Browser().Page("*")" to confirm the 'page' variable was set properly and it was.

       

      		if (0 == aqString.Compare(Sys.Browser().Page("*").Parent.ProcessName, "chrome", false))
      		    obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//span[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S_D']", true);
      		else
      		    obj = page.FindChildByXPath("//table[@id='tlEmployeeSiteAccess']//span[@id='SiteAccess" + AccessType[i] + "_" + SiteAccess[i] + "_S_D']", true);
      • TanyaYatskovska's avatar
        TanyaYatskovska
        Icon for Alumni rankAlumni

        You need to troubleshoot your XPath. Changing input to span was only my guess. Perhaps, something else was changed as well.