Unable to click an RadioButton with HtmlUnit - javascript

I'm having a terrible time on HtmlUnit, there's this Frame im into with an TextField, a Button related to the TextField, an RadioButton and another Button. In order to the RadioButton to be clickable i gotta fill the TextField and click for "Search", then click the RadioButton in order to click the last button in the form, which generates an List of contracts. Though it doesn't do so. I have like 99.999% sure that the RadioButton with 2 JS events isn't working, it has both an onMouseDown and an onClick event. I've tried trillions of different methods doing the same things, waited lifetimes for JavaScript with Thread.Sleeps() and waitFor's... Nothing seems to work, the JS events won't work or the RadioButton isn't being actually pressed, i know that because the last Button on the page returns me an error saying its conditions hasn't been fullfiled. Any idea what could be causing the RadioButton to just don't work? Im sure im referring correcly to it, i've tried XPaths, Id's, everything.
Thanks to whoever reads this and try to suggest something.

Related

How to track when a Radio button is clicked in Google Tag Manager without clicking the submit button/moving on from the page?

I've a pretty simple question but its been bothering me for a few days now. I want to track when someone clicks a radio button as a trigger or click, essentially to track the click and pull the data I need even if they haven't clicked submit or moved off the page. I just want to be able to do it when its clicked on the page but I can't seem to get my head around it in Google Tag Manager.
I ended up coming up with this so far but its pulling all clicks.
My solution was to create a custom variable that isolates the radio button by its class using Query Selector, then create a tag that fires on all clicks. The issue is that this is bringing back way more data than I need. It is bringing back random clicks on the page.
I tried to set it up in google tag manager as Some clicks, then set it to My Radio Variable - Equals - True but this didn't bring back anything at all.
My Radio Variable:
function () {
return document.querySelector('[class="radios__input"]:checked').id
}
I'm still new to this so any help would be greatly appreciated, thanks in advance.
This might require not only the variable.
Now you can get the id from the radio element which is great.
But you said it is returning a lot of other element you don't need so looks like it is lack of the trigger setting.
Trigger should be the important one in this scenario.
You can narrow down the range to only the radio element you want to track.
Like configure the trigger to
Click Element , match css selector , {Your special css selector to the radio button}
If you are not familiar about the above I mentioned. You can attach some screenshots about what is your trigger and variable and how you use it in your GTM.

Webpage doesn't refresh after input

Currently im working on automating a website with selenium python. I have this problem whereby when i enter J590 into the target textbox MANUALLY, i will have to click anywhere on the website or pressing tab which than will refresh the website and an option will be available in a dropdown box. However, selenium does not seem to be refreshing the page for me.
I tried to use click() before and after sending J590 into the textbox,i also tried using send_keys(Keys.TAB) after sending J590 but none is working.
Here is the code i used to send inputs
driver.execute_script("document.getElementById('CustCd').value+="+ dumps(jcode))
Here is the code i tried after sending input
driver.find_element_by_xpath('//*[#id="Item"]/form/center/input[2]').click()
or
driver.find_element_by_xpath('//*[#id="CustCd"]').send_keys(Keys.TAB)
May i know why is selenium acting this way and is there a solution to it.
Seems to be the keyboard/onchange event are triggering when you tab out or click on another element in the page as you are using js to enter the data. So, you have to dispatch (simulate) the corresponding event.
Refer to this post to know the associated event(s) to the element.
Let's say if you want to trigger onchange event on an element, then you should get the element first.
ele = driver.find_element_by_xxxx(yyy)
then send the event to the element using the js as shown below.
driver.executeScript("arguments[0].dispatchEvent(new Event('change', {'bubbles': true,'cancelable': true}));",ele)
Make sure you returned the correct element. And change the event name accordingly.

How to replace new search results with same submit button using AJAX vanilla javascript

I am completely stuck on how to do this. So far I am able to submit and make my searches appear, however when I make a new search it just adds on to the old search. I want to be able remove the old searches when the submit button is clicked on and replace it with my new search.
I have tried several ways but when I click on the submit button it ends up with no searches appearing.
If it helps, I am getting my data from an API.
Any suggestions would be much appreciated.
So far, I have added an eventListener to my button, which when clicked on makes a XMLHttpRequest(). Then it runs a for loop to extract my data.

Page does not submit after clicking on lower half of button when removing validations

I am facing an issue in my Struts2 application. Basically, on textfields, I have validations such as missing value, wrong value etc. There is then a button below these fields which submits the form when all validations are successful.
Suppose, I blur out of a textfield with a wrong value, the validation fires an error below this textfield. Now, when I supply a correct value and directly click on the upper half of the button, the validation clears and the page also submits along with it simultaneously. However, when I click on the lower half of the button, the validation just clears but the page does not submit at all. This behaviour is consistent across the application.
Now, the QA team has raised a defect for this as it could hamper user experience.
Could anyone suggest a possible fix for this other than calling the submit button click event on the mousedown event? We tried that but its causing side effects.
I cannot show the exact code as there are many collaborating CSS classes for this scenario which could cause confusion. If anyone could try to give a brief solution, it would be extremely helpful!
You need to perform the same function regardless of what part of the composite is invoked. If you click a submit button it should submit, if you click reset button it should reset. If you click cancel it should return to the previous page. Different functions of the same control mislead the user experience because it doesn't perform expected behavior of the button.

Simulate click on DIV

I am developing a desktop application in Delphi XE4 using TChromium component to display Google Voice webpage.
I need to start a call programmatically and I can't find a way to trigger the javascript code behind the button (it is a DIV) "CONNECT":
TChromium allows to execute javascript code and I already managed to simulate the click on "CALL" button using a javascript code that simulates the Key Event using the character "c" which display the panel. This works because Google Voice has shortcuts and "c" is a valid shortcut to start a call. Also with javascript I can set the number in the input field. My main problem is that I don't know how to simulate a click on "CONNECT":
As you can see, there is no ID, no onClick and there is no shortcut to trigger the Connect button.
I can get a reference to this DIV using the following code:
document.getElementById(":87.mi").children[0].children[0].children[5].children[1].children[0].children[0].children[0].children[1];
But it is not possible to trigger anything appending .click(). I assume it is because click() will trigger onClick method that it is not defined. Is there any way to know what javascript code executes when someone clicks over this div?
If the focus is in the "Number to call" input, I can press "TAB" to navigate to "Phone to call with", then to "Remember to choice" and finally to "Connect" where I can press Enter key to make it work also. I tried to use the same code as in the beginning to simulate the CALL button but this time with TAB (keycode 9 instead of 67) and it does not work as the focus does not move.
I tried to do it programmatically with delphi also using mouse_event, keybd_event, PostKeyExHWND, PostKeyEx32 and PostMessage with no results as the focus does not move away from "Number to call"
The only option that works by now is to move the mouse with delphi using SetCursorPos and simulate a click on that button calculating the coordinates but this will be my last option to choose as I would prefer a javascript code to do it.
Any suggestions are welcome!
I suggest the next solution.
In a javascript file that have to be imported from the view, put the next code:
$(".goog-button-base-content").click(function(){
//CODE HERE
});
What you do here is that everytime that we pressed the div that has that class, you will start the logic inside "CODE HERE"
(Sorry for my bad english)
I hope be usefully. See you

Categories

Resources