How to trigger onchange event without submitting the form?
Opened this issue · 2 comments
amiyatulu commented
let transfer_balance = self
.driver
.find(By::XPath("//*[contains(@name, 'transfer_balance')]"))
.await?;
transfer_balance.send_keys(amount.to_string()).await?;
transfer_balance.send_keys(Key::Return.to_string()).await?;
transfer_balance.send_keys(Key::Return.to_string()).await?;
The Return key submits the form instead of just triggering onchange. How to solve the issue?
html code in yew
<form onsubmit={onsubmit}>
<div class="mb-3">
<label for="Destination Account" class="form-label">{"Destination Account Address:"}</label>
<input name={"destination_account"} type="text" class={"form-control"} required={true} onchange={dest_account_onchanged}/>
</div>
<div class="mb-3">
<label for="Transfer Balance" class="form-label">{"Transfer Balance:"}</label>
<input name={"transfer_balance"} type="number" class={"form-control"} required={true} onchange={transfer_balance_onchanged}/>
</div>
if let Some(_value) = *spinner {
<input type="submit" value="Submit" disabled={true} id="tranfer-balance-submit"/>
<Icon icon_id={IconId::FontAwesomeSolidSpinner} />
} else {
<input type="submit" value="Submit" id="tranfer-balance-submit"/>
}
</form>
amiyatulu commented
Changed to oninput={}, and removed Key::Return, it works now. But not sure, how to do it, if such situation occurs in someone else code.
stevepryde commented
Is there a way for a user of your app to do it? If so, try automating that action.
Or you might be able to trigger it by running some custom JS via execute_script()
.
https://docs.rs/thirtyfour/0.32.0-rc.9/thirtyfour/session/handle/struct.SessionHandle.html#method.execute