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
Related
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.
I developed a page with only one button.
If a valid user appears i will allow that user to click that button
manually or user can also press enter(i will click that button using
js in background).
If a invalid user appears i will display a freeze layer on top of
that button, so that user cannot click that button.
Problem is if invalid user appears and press enter. my js code will click that button.
So, my question is straight forward is there any option in js to find whether user can click that button
I can also make alternate flow but i need to know answer for above question.
if(<user_is_not_valid_(your own condition)>){
document.getElementById("id_of_button").disabled = true;
}
This is for making a button unable to click. You should solve how to determine if the user is allowed to click. Put your own condition instead of < user_is_not_valid_(your own condition) >.
The user is valid or not is based on API request fire onpage load $.get in success you make the if (user.type==true){ $('#btn').addattr('onclick',funcname);}else{ ('#btn').attr('readonly',true);}
I want to click the "continue" which is given on the end of this page, note that the site is not mine, its someone else's. The element is located after the pagination,
I tried to click it this way :
//Method 1
document.querySelector(".se-pagination-button.se-pagination-button--next").click();
//Method 2
document.querySelector(".se-pagination-layout").lastElementChild.click();
But unfortunately it did not work for me. Is there anyway I can click it ? Because when you click it through the mouse or pad, it triggers a function. But not when I want to click it through the JavaScript.
That website is a hot mess of different systems, but they use Vue.
So what you are looking for is:
document.querySelector(".se-pagination-button.se-pagination-button--next").__vue__._events.tap[0]()
I am trying to figure out on a Watir browser with ruby, how to use a mouse click and grab the element. Mostly what I find is using css selectors to identify elemnts but that is not my issue. I also find how to click the ouse, which is also not my issue.
I want to first stop when a user clicks on my broswer then give them the option to extract the element being clicked. I intend to use this element in the code to drive the rest of the program.
Now whether its xpath or what ever it is, I have search and am unable to get the return of the mouse click. Any help is appreciated.
I use:
browser = Watir::Browser.new(:firefox) // or chrome
browser.goto("website.com")
//ideally at this step I want to wait the script for user input
//if they click then I identify the element they click
Then later..
doc = Nokogiri::HTML.parse(browser.html)
I am using HTML on a Raspberry Pi to control relays, currently I have a button for the On and another for the Off of the GPIO, I was wondering if there was a way I could press a single button once to call the On.php and press the same button a second time to call the Off.php without leaving the page.
Right now one button moves to the PHP script page which turns the GPIO On and then returns to the home page, the Off button does the same. This is a bad method but it worked.
Seting a global variable to calculate the times of your clicking (flag==0). Then writing something to define which functions you want to use.
I used a checkbox for the input, a function is called when the box is clicked which then checks if it is ticked or not, the code then uses a variable to decide what state the GPIO Pin should be in.