Basically I am currently writing a Python Requests program and everything works fine so far, The issue is there is a button on the website that I want to be pressed. Currently the clicking stage is done in selenium which slows the process down completely.
Just like when filling in a form is there anyway to pass a parameter into a URL to click a button?
The button sends a POST command to a URL when clicked however when trying to recreate this in a browser or in python with .post the desired redirect does not happen.
Any help is much appreciated.
Related
Currently I am testing my flask app using selenium. So I have an html with simple FlaskForm in it which contains submit button. Of course I can click on it and submit a form using
btn = driver.find_element_by_id("submit-btn").click()
But the problem is that click method doesn't return anything.
So my question is how can I get at least the response code of submitted form so I can be sure that my tests run ok?
No, click() does not return anything, and you cannot get response code by selenium as well.
You need to verify test based on what the web displays, like success alert, text or something.
I am trying to automate a task with selenium, using Firefox.
I wrote all the code, and it worked perfectly with headless=False, but when I changed it to headless=True, it suddenly did not press some of the buttons - the ones that transfers to a different page works, but the other ones (They should be pressed to register to a service) did not (I know they did not work because when I checked if I was registered after running it, I was not - which was not the case with headless=False).
I printed what is written on the buttons which did not work, so I know the program recognises them, and because I was able to get there I know the other buttons got clicked and responded well.
All buttons was specified the same way (I tried both XPath and CSS Selector).
Any ideas for why it happens and how to fix it will be appreciated.
Thanks!
Note: This site requires username and password, so I don't think it would be useful to add a link.
I am trying to add connections on Linkedin with Selenium.
I am running into a problem when I try to click each "Connect Now" button. There is a small window that pops up and the script isn't able to click the button. I have tried to click the link and then use driver.find_element_by_class_name('button-primary-large ml1').click()
Side question - How do I connect large and ml1?
When I run the code, it is clicking to connect but then it has a problem trying to click "Send Now" which is what the code above is trying to do. What is a good way for me to click the send now button? I am posting pictures to show what I mean.
You can click the button by using
driver.find_elements_by_css_selector('.send-invite__actions button.button-primary-large').click()
I'm currently trying to right a python script that overnight turns off all of our EC2 instances then in the morning my QA team can go to a webpage and press a button to turn the instances back on.
I have written my python script that turns the severs off using boto. I also have a function which when ran turns them back on.
I have an html doc with buttons on it.
I'm just struggling to work out how to get these buttons to call the function. I'm using bottle rather than flask and I have no Java SCript experience. So I would like t avoid Ajax if possible. I dont mind if the whole page has to reload after the button is pressed. After the single press the webpage isnt needed anyway.
What I have ended up doing to fix this issue is used bottle to make a url which completes the needed function. Then just made an html button that links to the relevant url.
I need to login to a website. Navigate to a report page. After entering the required information and clicking on the "Go" button(This is a multipart/form-data that I am submitting), there's a pop up window asking me to save the file. I want to do it automatically by python.
I search the internet for a couple of days, but can't find a way in python. By using urllib2, I can process up to submitting multipart form, but how can I get the name and location of the file and download it?
Please Note: There is no Href associated with the "Go" button. After submitting the form, a file-save dialog popup asking me where to save the file.
thanks in advance
There are python bindings to Selenium, that are helping in scripting simulated browser behavior allowing to do really complex stuff with it - take a look at it, should be enough for what you need.