Answered

Trying to change date format

Need to change date format from Month day, Year(Eg: January 25, 2023) to MM/dd/yyyy format.  Tried using Set date, but getting incorrect date.  The result variable gets 1/1/2023 instead of 1/25/2023

 

 

1
10 comments
Avatar
Rex Feizi

I think the source format is wrong. Could you please try MMMM d, yyyy. 

I ran the following on my machine. 

0
Comment actions Permalink
Avatar
Sukumaran, Neema (NIH/NHLBI) [C]

Hi Rex,

Thank you. Really appreciate your help.  it worked. Spent lot of time on this last 2 days trying different options.  I have one more scenario I am trying to automate.  It would be very helpful if you can suggest a solution for this.  This is to verify background-color of a button when hovered over. I tried Hover option.  But when tried to get-web-value to get color, it loses hover effect.  I cannot use Hover and click as the button will disappear if clicked (it basically clears that filter)

0
Comment actions Permalink
Avatar
Rex Feizi

Neema, 

Just to confirm, are you trying to validate that hover changes the background color of a given button? If not, please elaborate. If yes, then you need to share the HTML snippet of the button. Many times where there are layers of elements the event is defined by an inner or outer element. You don't have to share the entire HTML section, only the segment around the button mostly its ancestors.  

0
Comment actions Permalink
Avatar
Sukumaran, Neema (NIH/NHLBI) [C]

Hi Rex,

yes,  i am trying to verify that hover state is applied.  Without hover, the background-color of button is #102d66 and when hovered it should be #20558A.  Pleas see the screenshot below.  Please let me know if you need elaborate screenshot with hierarchy

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Neema,

So just to confirm, using get_web_value / with css and property: background-color gives you #102d66, but when you use Hover command, executing get_web_value makes the hover lose focus and also gives you #102d66 ?

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Sukumaran, Neema (NIH/NHLBI) [C]

hi Joseph,  

yes,  once i use hover i can see the button color changing.  but in next step when get-web-value is used, it pulls same color, #102d66

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Neema,

Thanks for confirming. Can you please try the below:

1. In Get_Web_Value, add a variable name, select JavaScript and enter the below (Replace the XPath in the first line with the XPath for your button)

const xpath = "//button[contains(text(),'Hover me')]"; 

const element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

const bgColor = window.getComputedStyle(element).getPropertyValue('background-color');

function rgbToHex(rgb) {
  const hex = Number(rgb).toString(16);
  if (hex.length < 2) {
    return '0' + hex;
  }
  return hex;
}

if (bgColor.indexOf('rgb') !== -1) {
  const rgbValues = bgColor.match(/\d+/g);
  const hexValue = '#' + rgbToHex(rgbValues[0]) + rgbToHex(rgbValues[1]) + rgbToHex(rgbValues[2]);
return hexValue;
}

2. After that, please copy the same step and place it after your Hover step, then execute the test.

Please let me know if this works.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Sukumaran, Neema (NIH/NHLBI) [C]

Hi Joseph,

Thanks a lot.  i changed the xpath to const xpath = "//ul[contains(@class,'facet-summary__items')]/li[2]"; and it works.  Thanks again for the help.  

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Neema,

Anytime, thank you so much for confirming and we're glad it's working for you. 

I hope you don't mind, we will create a separate post for this issue with the above solution to assist others in finding it in case they run into the same thing.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Sukumaran, Neema (NIH/NHLBI) [C]

Sure ,  that will be helpful .  Thanks

0
Comment actions Permalink

Please sign in to leave a comment.