I am currently using pyautogui to automate a web application. I am very new to the software so every single step has been a learning experiennce. I am currently trying to select a specific checkbox however since there are multiple check boxes I am not able to do so. I am currently using a screenshot of the checkbox icon in order to click on it so I figured this was my problem. Is there anyway in pyautogui to select a specific image even if there are duplicates present?
I've tried playing around with the coordinates, but since this application needs to be as user friendly as possible I thought setting specific coordinates could be tricky.
Checkcoords=pyautogui.locateOnScreen("checkbox.png"#Locate the checkbox, but since there are multiple checkboxes it just goes to the first one present and not the one that i need
pyatuogui.click(Checkcoords) # used to click the checkbox
Not getting any error messages, just goes to the wrong checkbox.
Related
I am facing the situation where I have to automate certain stuff, the exact scenario is I have the game loaded in the canvas, and I can able to do the click actions inside the canvas(using Actionchains offset by selenium in python) but on click, there are certain actions happening on the game like it will display some values on button click and the values get changed on every click action of the button, Here I need to fetch those text(values).
By using selenium and python, I can able to achieve only the click actions, but what exactly I need is to fetch the text displayed on the canvas. Help will be much appreciated, Thanks in advance.
I'm new to using Selenium, and I am having trouble figuring out how to click through all iterations of a specific element. To clarify, I can't even get it to click through one as it's a dropdown but is defined as an element.
I am trying to scrape fanduel; when clicking on a specific game you are presented with a bunch of main title bets and in order to get the information I need to click the dropdowns to get to that information. There is also another drop down that states, "See More" which is a similar problem, but assuming this gets fixed I'm assuming I will be able to figure that out.
So far, I have tried to use:
find_element_by_class_name()
find_element_by_css_selector()
I have also used them in the sense of elements, and tried to loop through and click on each index of the list, but that did not work.
If there are any ideas, they would be much appreciated.
FYI: I am using beautiful soup to scrape the website for the information, I figured Selenium would be helpful making the information that isn't currently accessible, accessible.
This image shows the dropdowns that I am trying to access, in this case the dropdown 'Win Margin'. The HTML code is shown to the left of it.
This also shows that there are multiple dropdowns, varying in amount based off the game.
You can also try using action chains from selenium
menu = driver.find_element_by_css_selector(".nav")
hidden_submenu = driver.find_element_by_css_selector(".nav # submenu1")
ActionChains(driver).move_to_element(menu).click(hidden_submenu).perform()
Source: here
I've been trying to figure this out for a week now. I'm attempting to find a way to allow a user to select an element on a webpage and to return that element ID.
Either of these two processes would work.
The user could click an element to identify the element ID, like with an element selector.
The program could display a list of all elements of a certain type like a checkbox, and the user could select which checkbox/text field/button to interact with. I tried to do this with the below code using Selenium, but for some reason this code just returns [] no matter how many checkboxes are on the page.
checkboxes = driver.find_elements_by_css_selector("#data_configuration_datamaps_ct_fields_body input[type='checkbox']")
print(checkboxes)
Every time I find a way to do this, it's with another programming language. When I've tried to ask this in various discords and subreddits, I'm always told to post the specific element I'm trying to work with.
The problem is, I'm trying to do this to develop tools to help my own workflow when doing RPA. So I need a way to select an element at runtime and not to predefine it.
I'm able to do this with other programming languages but have not found a way to do it with Python despite everyone saying Python is ideal for automation.
Is there really no way to accomplish this?
This is my first post so bear with me. I'm trying to go into a dropdown list (Products) that is located in a toolbar at the top of the webpage. Once hovering over the dropdown Products, I'd like to click the one that is named ModMaster so I can navigate to the link 'https://www.modmaster.com'. How do I go about doing this?
I've tried several different methods but the core issue is that's unable to locate the element. If I explicitly wait for it to be visible, it times out.
I've tried using Select, javascript execute, simple find_by_element.click to no avail.
Really the end result just needs to be the current webpage needs to change into www.modmaster.com and keep me logged in. I appreciate any help!
Here is the HTML:
`<ul class="topbar-module-wrap"><li class="topbar-module"><div class="login-info dropdown"><span>Welcome, hidden</span><ul class="dropdown-menu"><li><label>User name:</label> hidden</li><li><label>Agency:</label> hidden</li><li class="divider"></li><li>Log out</li></ul></div></li><li class="topbar-module"><div id="product-dropdown" class="product-menu dropdown"><i class="icon-menu-white-small"></i><span>Products</span><ul class="dropdown-menu"><li><div class="topbar-product-name">Account Management Center</div><div class="topbar-product-subtext"></div></li><li><div class="topbar-product-name">Broker Briefcase®</div><div class="topbar-product-subtext">Sales and Marketing Platform</div></li><li><a href="https://www.modmaster.com/" target="_blank"><div class="topbar-product-name">ModMaster®</div><div class="topbar-product-subtext">Mod Analysis Tool
I'm trying to programmatically manipulate an internal website via python. It's actually working for the most part, but I'm stuck trying to trigger a POST request after the value of each box changes. I can see in the Chrome debugger that a POST request is made after I click on a value in one of the select boxes.
For example, there are three select boxes and each one is dependent on the last.
When a value is selected in select box A, select box B is populated via AJAX.
When a value is selected in select box B, select box C is populated via AJAX.
The items in select box A are statically loaded when the page is loaded. I can iterate through those with no problems.
import win32com.client
ie = win32com.client.DispatchEx("InternetExplorer.Application")
ie.Navigate("...")
# stuff to see if the page loaded...
boxAObj = doc.getElementById("selectBoxA")
for i in range(1,boxAObj):
# I've tried this multiple ways - none have triggered the request
boxAObj.options.selectedIndex = i
boxBObj = doc.getElementById("selectBoxB")
print boxBObj.length
The print statement always prints 1. There was a default value in the select box "Select...", so that's why the length is 1.
Here are some images of the site to show the behavior. The first one is after a fresh page load with nothing selected either by the mouse or via javascript.
In this picture, I programmatically selected an item in select box A using javascript, but nothing was loaded in select box B:
In this picture, I clicked the same value in select box A and you can see that select box B populated as expected:
The last piece of information is that the select boxes have onchange events assigned to them. Is that the key to this problem?
Edit: I just found a post that shows obj.onchange() from javascript should do the trick, which works in the browser, but not from python. Should I try to eval the function in python? I've tried a few things, but nothing has worked yet. See below: