Selenium Python - How to get class id by clicking on it manually - javascript

I'm trying to click on a button on a page that has a lot of JavaScript but no matter what I try, can't click it. Is there a way for me to click the button manually and get what I need to click?
I've tried inspecting elements and FirePath but those aren't giving me the correct class or id that I need to click
Edit: This is what I'm trying to accomplish, the below is from Selenium IDE firefox plugin
Command Target
open /logger/summary.ftl
clickAndWait link=System Admin
selectFrame sysadmin-content
click //div[#id='sysadminmenu__sysadminmenu_x-auto-29']/span[3]/span
click id=x-auto-178

You may try
http://www.seleniumhq.org/projects/ide/
This has a feature to find web element path

Related

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 pause Watir script to allow user to click, and capture what they clicked on.

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)

Simulate click in web.whatsapp.com

My mission is export my whatsapp contacts with profile picrures.
So I decided to make a chrome extension for this purpose.
And Here to collect phone of each I have to click them. And each time go back to contact list I guess. The button I got a problem to click on by javascript code is
I need to click on this button by code and get full contact list
I can find this elem by query like
$('.menu-horizontal span .menu-horizontal-item:nth-child(2)')
But when I tried to click on this element - nothing happens
$('.menu-horizontal span .menu-horizontal-item:nth-child(2)').click()
Any ideas... please!!!!. I just need to open contacts panel each time!!
I have added and used jquery but It's ok to use vanilla JavaScript
I'm using simulating click function in my extension - https://gist.github.com/davojta/3647dfbf006bec75f6ef7e3f8d2f3e70

website blocks document.getElementById javascript injection

I am looking at this website in particular www.nadex.com
When you log into their platform you can see that the ID of the place order button is "ticket5_orderTicketButton" but when I use that ID to simulate a click it returns that the ID is not on that page. I have tried this with several different IDs and they all do this.
This is the only website I have ever encountered that does this and I am wondering how do they do this, but more importantly how can I still simulate the button click with JavaScript?
Thank you, and I attached a picture below to show what I mean.
ticket5_orderTicketButton

Clicking with Selenium?

I looked around, but I wasn't able to find anything that answered the question that I have at hand. I want to click a button with Selenium, but the button ID is dynamic (meaning it changes after EACH button press). I would like to click the button via it's value, but with Selenium IDE, the Firefox extension, I'm not positive how I could go about this. Here's the coding of the button that I'm trying to click, with Selenium.
<input id="move247957048" type="button" style="width: 120px" value="Sacred Sword">
The input id="move" that you see, it changes every single time I click this button. All of it changes except for the first digit, the 2. With Selenium, I have no clue whatsoever about how I could click this button via it's value, or whatever would work. D: It's repetitive as well, so it'd handle it multiple times.
In Selenium IDE you can use xpath defined locators, in your case I would use next xpath //input[#value='Sacred Sword']. You can find it in related documentation http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#test-case-pane

Categories

Resources