When I click a button using Selenium IDE I get 2 results in the "Table" tab:
selectFrame {"id":"3f923370-2dae-80d8-f36f-670e9caa7f7d","containerVersion":"7-GA","webContextPath":"/mmm"}
and
click xpath=(//button[#type='button'])[2]
How do I turn this into usable code in python? Using driver.switch_to_frame and driver.find_element_by_xpath ??
You need to first switch to the specific frame and then search for the element in the frame. You can try this:
driver.switch_to_frame(driver.find_element_by_id("3f923370-2dae-80d8-f36f-670e9caa7f7d")
driver.find_element_by_xpath("//button[#type='button'][2]").click()
I'm not familiar with Selenium IDE but I'm assuming that 3f923370-2dae-80d8-f36f-670e9caa7f7d is the id attribute value of the frame tag.
Related
HTML
How would you click on this particular item in selenium each time by having just the date you want as a variable? I have shown the item in the attached image of the HTML. It is a panel calendar, however, I can't find the item using by.ID, class, etc. I can Click on it by using XPath however how do I make it specific to the data? I would like to click on it based on the.
data-moment="2022-10-30"
currently I just have this:
### Gets Edge driver and doesnt need extension update
driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install()))
driver.get(
'https://teewire.net/granada/'
)
driver.maximize_window()
pause(5)
driver.find_element(By.XPATH,"//*[#id='gz-time-slot-calendar']/ul/li[4]/a").click()
pause(10)
Change your XPath to this:
data_moment = "2022-10-30"
driver.find_element(By.XPATH,f"//*[#id='gz-time-slot-calendar']//a[#data-moment='{data_moment}']").click()
HTML screenshotI am trying to build a test case to select an option from the drop down menu but unable to find the element.
I am new to selenium webdriver module I can find elements using xpath and id but unable to find an element from a drop down menu.
I am able to log into the webpage and click "Queues". Now I want to select "All Items" from the queue but gettig errow
All Items
If you are not able to find it by selenium and exception is throwing like element not found that probably there is a frame present and your element is inside it. you need to switch to the frame first.
You can refer my or other answer in below link:
How to select frame if there are multiple frames on a webpage and get content of that frame?
If you are not able to find in HTML then use below code
System.out.println(driver.getPageSource());
It just going to print your HTML, now copy it in notepad++ and search your dropdown Text. now create Xpath
I'm trying to use VBA to navigate to a website and then extract some data. So far I've been able to navigate to the website and, but I can't figure out how to click on the buttons I need. Based on the research I've done, using querySelector is a much better option than using getElements.
When I inspect the button I'm trying to click on it brings me to the following line in IE's DOM explorer
<INPUT width="80" class= "button" onclick= "updateSummary();" type= "button" value="Apply Filters"></input>
Based on my research, I've got the following:
.
.
.
Ie.document.queryselector("input[value=Apply Filters]") (0).click
But I get a
runtime '438' object doesn't support this property or method.
I'd also like to be able to click on an "Export to CSV" button, and the html code has an href component and a source = "dynamically changing code based on the day" component.
Would it be possible to click on the export to to CSV button and either open the file or save it in a folder?
Thanks so much for the help!
Two things:
As mentioned in comments, drop the zero as you are not dealing with a nodeList. querySelector returns a single node which is the first match for the specified selector, or null.
You cannot pass a selector for attribute value that contains spaces without enclosing within ''
ie.document.querySelector("[value='Apply Filters']")
You could also use:
ie.document.querySelector("[onclick='updateSummary();']")
Is it true that DIV elements cannot be clicked with selenium Web Driver?
For Instance, I'm unable to click on delete button in Gmail
Am trying to locate the elemnt using XPATH = //div[#aria-label='Delete']
here, class names and id's are dynamic which changes for every session. Imean, for every Login and Logout. I want my script to be Robust to run at any time.
You can by class name or ID, e.g. with class:
driver.findElement(By.className("class")).click();
Or by element name:
driver.findElement(By.ByTagName("div")).click();
Or find the parent or child a tag.
Have you tried using a different attribute ?
For e.g. you can use
//div[#data-tooltip='Delete']
or
//div[#data-tooltip='Delete']/div/div
It may derive because of gmail has async structure. You may wait to finish request after page load and after select action. If you can share code flow we can examine together.
I am using a jQuery plugin named "Table-to-JSON" (http://lightswitch05.github.io/table-to-json/) in order to convert an HTML table to a JSON object. Everything works smoothly.
My problem has arisen when I use another jQuery library "jQuery UI Tabs" to have multiple tabs within a single HTML file.
On each tab I have a table. At the bottom of the page I have a save button. I would like to give the chance to users to press the save button and for each table in each tab the corresponding JSON object to be saved.
The problem is that when you press the save button, you can only save/export the JSON object of the current (selected) tab. Add some more tabs and then, when you try to export(alert) the JSON object of each table in each tab (only the table of the selected tab is exported) , the rest of them are empty [] as you can see in my jsfiddle example provided below.
I would like to export all the JSON objects of each table in each tab.
Is it a jQuery issue regarding IDs? or table-toJSON library does not work with jQuery-UI tabs?
Any advice would be appreciated.
there's an option for the function tableToJSON called ignoreHiddenRows.
set this option to false to accomplish what you need.
here's the fiddle : http://jsfiddle.net/7t5cB/