I am building a headless crawler running JavaFX Webkit, it definitely is not as powerful as chrome's v8.
However I've run into problems lately, wherein I am trying to input a value to react rendered input fields.
Here's what I have done till now and failed.[ Note: I don't have control over the source / React code. Since I am trying to crawl a destination site ]
- jQuery -
$('input.r_input').val("2");
- Vanila JS -
document.querySelector("input.r_input").value = "2";
- Trigger change events through jquery trigger - change, blur , keyup, keydown, etc.
Creating a manual event like :
event = new Event( event, {target: obj, bubbles: true} ); event.simulated = true; return obj ? obj.dispatchEvent(event) : false;
and triggering an input
event.
None of the above works.
I am adding parts of react code from the JS file on the website if it may help to add some more context.
Create:
t.prototype.createInputProps = function(e) {
return {
disabled: this.props.submitting || e > this.focusIndex,
className: "r_input",
type: "tel",
name: "tan-" + e,
maxLength: 1,
pattern: "[\\d]*",
tabIndex: 0,
placeholder: "·",
autoComplete: "off"
}
}
Render :
t.prototype.render = function() {
var e = this.props,
t = e.meta,
n = t.touched,
r = t.error,
o = (e.input.value, sa()("r_input", {
"has-error": r && n
}));
return us("article", {
className: o
}, void 0, us("div", {
className: "r_inputs"
}, void 0, ro.a.createElement("input", as({
onPaste: this.handleOnPaste,
ref: this.addInputToList,
onKeyUp: this.handleKeyUp,
value: this.getValue(0)
}, this.createInputProps(0))), ro.a.createElement("input", as({
ref: this.addInputToList,
onKeyUp: this.handleKeyUp,
value: this.getValue(1)
}, this.createInputProps(1))), ro.a.createElement("input", as({
ref: this.addInputToList,
onKeyUp: this.handleKeyUp,
value: this.getValue(2)
}, this.createInputProps(2))), ro.a.createElement("input", as({
ref: this.addInputToList,
onKeyUp: this.handleKeyUp,
value: this.getValue(3)
}, this.createInputProps(3))), ro.a.createElement("input", as({
ref: this.addInputToList,
onKeyUp: this.handleKeyUp,
value: this.getValue(4)
}, this.createInputProps(4))), ro.a.createElement("input", as({
ref: this.addInputToList,
onKeyUp: this.handleKeyUp,
value: this.getValue(5)
}, this.createInputProps(5)))), n && r && us(is.a, {}, void 0, r))
}
Not sure If I need to add handleKeyUp
, but that contains some validation code.
Any help will be appreciated.