Hello everyone ,
I'm trying to write a function that detects if an element is written in bold or italic.
If i directly give the element like follow :IT DOES WORK !
public static void CheckIfBold(){
var dayInTransferWeek = PumaRepo.ApplicationUnderTest.dayInTransferWeek;
String font = dayInTransferWeek.GetStyle("font-weight");
Validate.AreEqual("700", font);
Report.Info("element gras"+font);
}
But i want to generalize it the way i give the function the element i want , so i have written this function but IT doesnt work
public static void CheckIfElementIsBold(RepoItemInfo Element){
String font = Element.GetStyle("font-weight");
Validate.AreEqual("700" , font);
Report.Info("element gras"+font);
}
}
I get this error
'Ranorex.Core.Repository.RepoItemInfo' ne contient pas une définition pour 'GetStyle' et aucune méthode d'extension 'GetStyle' acceptant un premier argument de type 'Ranorex.Core.Repository.RepoItemInfo' n'a été trouvée (une directive using ou une référence d'assembly est-elle manquante ?) (CS1061)
please help!
Unable to get Style of Element
Re: Unable to get Style of Element
Hi,
Just rename “Element” to something else. Like. “repoElement”. “Element” is a reserved keyword so it confuses Ranorex if used like you did it
Just rename “Element” to something else. Like. “repoElement”. “Element” is a reserved keyword so it confuses Ranorex if used like you did it
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Unable to get Style of Element
Hello ,
I did what u said
public static void CheckIfElementIsBold(RepoItemInfo repoElement){
String font = repoElement.GetStyle("font-weight");
Validate.AreEqual("700" , font);
Report.Info("element gras"+font);
}
}
I get the same error , telling 'Ranorex.Core.Repository.RepoItemInfo'doesnt contain definition of 'GetStyle'
I did what u said
public static void CheckIfElementIsBold(RepoItemInfo repoElement){
String font = repoElement.GetStyle("font-weight");
Validate.AreEqual("700" , font);
Report.Info("element gras"+font);
}
}
I get the same error , telling 'Ranorex.Core.Repository.RepoItemInfo'doesnt contain definition of 'GetStyle'
Re: Unable to get Style of Element
Hi,
Sorry, my mistake. I forgot to mention that you must create an adapter from RepoItemInfo object. Like this:
Sorry, my mistake. I forgot to mention that you must create an adapter from RepoItemInfo object. Like this:
Code: Select all
repoElement.CreateAdapter<Ranorex.WebElement>(true).GetStyle("font-weight");
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Unable to get Style of Element
It worked ! Thanks a lot