Thank you for getting back to me with additional details.
I reviewed the code you have prepared to decide on which element you need to perform the right click. Still I am not sure what the is the failure you encountered and how the application's elements are structured, though there are few things to mention.
It seems that you need to find on page the div
element with the class which ends on alternate
- however, the current code will fail at the line, which defines the HtmlDiv str
, if there is any case, when the page does not contain an element with that class. That way, the execution will never proceed further to the if..else
Then, you probably want to compare the class name of that located HtmlDiv str
with the string you had defined. Though, the used str.ToString();
will certainly not return the class name.
The way you compare strings in the condition part of the if..else
block will probably also not return what you expect it to return. Here
are some guidelines on the topic how strings are compared in C#.
I noticed you are using the tilde (~) sign in the class name to define an element - this indicates that the class should contain the mentioned string. If leaving the code as it is at its current state, defining the myDiv
in the else
block, will point to all the div
elements on page with any of the two classes, we are focused on.
Having that said, I am still not sure what is the scenario you need to cover and what is the failure information when you try to execute the test. Therefore, if you need additional assistance on the case, I will appreciate if you can share some details on the below topics:
- Which is the element you need to right click on - the one, which contains 'alternate' in its class name, or the one, which doesn't?
- How do you decide which of the two elements should be right clicked?
- How these elements appear and are listed in the DOM tree? Are these always grouped like this?
- Can you please execute the test and collect the step failure details
- you can use the Export
button to get the necessary data zipped and send it via this thread.
I hope the above will help you sort out what still needs to be adjusted. Please, elaborate on the mentioned topics, if you will need additional assistance on the case. Thanks in advance.