enter image description here
enter image description here
HI want to build an automation that will extract the shipping address of a customer from the element that on the attached picture - and I need help - with figuring out how to extract the value of the city to make the automation. I tried to extract the CSS and the XPath selectors with Chrome extensions but the selectors that provided via Chrome extensions are not providing any results
For example - please advise how to get the CSS or XPATH selector of the "City" value from this piece of code:
<div class="control-group">
<label for="city" class="control-label" data-i18n="[html]c706c0f0-16af-4c60-89de-0714aff0b08a">City</label>
<div class="controls">
<input type="text" placeholder="" class="m-wrap span12" name="city">
</div>
</div>
I watched tutorials on youtube , tried ask AI , and also many different variation of selectors but nothing work. Any help will be appreciated.
enter image description here
enter image description here
HI want to build an automation that will extract the shipping address of a customer from the element that on the attached picture - and I need help - with figuring out how to extract the value of the city to make the automation. I tried to extract the CSS and the XPath selectors with Chrome extensions but the selectors that provided via Chrome extensions are not providing any results
For example - please advise how to get the CSS or XPATH selector of the "City" value from this piece of code:
<div class="control-group">
<label for="city" class="control-label" data-i18n="[html]c706c0f0-16af-4c60-89de-0714aff0b08a">City</label>
<div class="controls">
<input type="text" placeholder="" class="m-wrap span12" name="city">
</div>
</div>
I watched tutorials on youtube , tried ask AI , and also many different variation of selectors but nothing work. Any help will be appreciated.
Share Improve this question asked Mar 19 at 14:41 Pro4automationsPro4automations 12 bronze badges 1- 1 Code must be posted as plain text, not images. – LMC Commented Mar 19 at 14:45
1 Answer
Reset to default 0Using document.querySelector
(Best Approach)
let cityValue = document.querySelector('input[name="city"]').value;
console.log(cityValue);
//Using getElementsByName
let cityInput = document.getElementsByName("city")[0];
console.log(cityInput.value);
//Using getElementsByClassName
let cityValue = document.getElementsByClassName("m-wrap span12")[0].value;
console.log(cityValue);
Edit
If your app accepts CSS selectors, use:
input[name="city"]
If your app accepts XPath, use:
//input[@name='city']
Both will select the city input field, and your automation tool should be able to fetch its value!