Jump to content

Recommended Posts

Posted (edited)

I have an input field which is preallocated with suggestion values and I can type in my own values.
The values I type in are automatically separated if I type "," or enter after the value.

This is the field:

TagsField.jpg.f9943a98d53ebd90cb2f36a96dafa14b.jpg

Tags are deleted if I click on them.
They are also deleted if I click after the last tag and then click Backspace.
Every backspace deletes one tag.


The problem is that I only want to use my own values. So I have to delete the preallocated values.
I tried to delete the preallocated values this way:

;this clear doesn't work:
;/html/body/div/div[1]/ui-view/div/div/div/div/div/div[2]/div[1]/div/div[3]/div
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, _
"//div/div[1]/ui-view/div/div/div/div/div/div[2]/div[1]/div/div[3]/div")
_WD_ElementAction($sSession, $sElement, "clear")
Sleep(500)

;this clear also doesn't work:
;/html/body/div/div[1]/ui-view/div/div/div/div/div/div[2]/div[1]/div/div[3]
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, _
"//div/div[1]/ui-view/div/div/div/div/div/div[2]/div[1]/div/div[3]")
_WD_ElementAction($sSession, $sElement, "clear")
Sleep(500)

;go into the input field
;/html/body/div/div[1]/ui-view/div/div/div/div/div/div[2]/div[1]/div/div[3]/div/div[1]/span/div/div/input
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, _
"//div/div[1]/ui-view/div/div/div/div/div/div[2]/div[1]/div/div[3]/div/div[1]/span/div/div/input")

;delete of tags doesn't work:
;I don't need tag q. I set it only to be after the last tag.
;New tags are automatically set after the last tag
;I try to go to the end of all tags and the press backspace until all tags are deleted
_WD_ElementAction($sSession, $sElement, "value", "q"); -> works value is set
Sleep(500)
For $g = 1 To 25
    ;Console Output: _WD_ElementAction ==> Invalid data type: (Name|Rect|Text|Selected|Enabled|Displayed|Active|Attribute|Property|CSS|Clear|Click|Value|Screenshot) $sCommand=>key
    _WD_ElementAction($sSession, $sElement, "key", "{BACKSPACE}")
    Sleep(500)
Next

;this also doesn't work:
_WD_ElementAction($sSession, $sElement, "clear")
Sleep(500)

This is the html structure:

TagsHTMLStructure.thumb.jpg.c5bdbdb3cc8b082e42693d79aa852b9b.jpg

So is there a way to delete the preallocated tags from the field?

Edited by AI123
Posted

To send a backspace try this :

$sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE003"}, {"type": "keyUp", "value": "\uE003"}]}]}'
_WD_Action($sSession, "actions", $sAction)

 

Posted
25 minutes ago, Danp2 said:

I'm sure it can be done, but not with the limited information supplied. I would need access to the website or details on the library that implements the element.

The website is spreadshirt . de. I have an account there. It can only be tested with an account there.

The solution by Nine works, so I don't need further help for this. But thank you for your effort.

Posted (edited)
31 minutes ago, Nine said:

To send a backspace try this :

$sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE003"}, {"type": "keyUp", "value": "\uE003"}]}]}'
_WD_Action($sSession, "actions", $sAction)

 

Thank you, that works. 🙂 Is it right that the action will be done on the Window/field that has the focus? So if I have an text editor additionally open and click on it the backspace would be done there instead of the browser?

Edited by AI123
Posted
1 hour ago, AI123 said:

Is it right that the action will be done on the Window/field that has the focus?

No the backspace will always be performed on the opened Chrome session no matter what window has the focus.

Posted
18 minutes ago, Nine said:

No the backspace will always be performed on the opened Chrome session no matter what window has the focus.

Oh, that's good. Thank you for the information.

  • 2 months later...
Posted

Chào @Nine .

I also had a similar situation. I have tried many ways but it failed. Hope you can help me.

I can't remove value in input . but when i left click to input before code run => then it will be deleted .

<input name="quantity-input" id="quantity_retail-input" required="" value="14897292522770823" class="wt-input " aria-describedby="quantity_retail-help" aria-invalid="true">

I have use your code to click before remove value but it don't work . 
 

$sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown"}, {"type": "keyUp"}]}]}'
_WD_Action($sSession, "actions", $sAction)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='quantity_retail-input']")
_WD_ElementAction($sSession, $sElement, "clear")

thanks nine :( :(

xxxxxxxxxxx

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...