How do you handle dynamic cookie buttons in Selenium? - selenium

I'm trying to click the 'Allow essential and optional cookies button' which pops up on Facebook.
button = driver.find_element(By.XPATH,"//button[#id='u_0_e_EQ']")
button.click
the error is that the id (u_0_e_EQ) changes every time the page is reloaded. Is there any way to get around this?

If the button label is unique, you can use it.
driver.find_element(By.XPATH,"//button[text()='button_label']").click

Related

How to handle modal/ pop-up using automation

Tried to handle the pop-up many ways, need clarity do we need to change the body. because when the pop-up is displayed the new class is adding it is as below.
https://i.stack.imgur.com/jQC2B.png
The actual Pop-up class is as below. there is no close button for this pop-up.
https://i.stack.imgur.com/e1ZWc.png
-By manual user can close the pop-up when user click any where in the page. When i tried click any where using automation it is displaying as element not found
Here is the code i user to handle the pop-up i am so confused how to handle the pop-up
https://i.stack.imgur.com/ibf0j.png
Thanks for help in advance
please try to check the javascript from where this pop-up is executing and try to disable display property by setting it to none
Try to remove this div class name "_355Q0" from DOM. by using this javascript query.
var myobj = document.querySelector("._355Q0")
myobj.remove();

Using puppeteer to automate button clicks for every button at every URL in a web app

I am currently trying to use JS and puppeteer to take a screenshot of every url in my web app, as well as take a screenshot of every button that can be clicked. Is there a way to click each button without specifying the id? Not all of my buttons have an id and even if they did, I wouldn't want to have x number of page.click(id, options) for each button I have (which is quite a lot).
Thanks
I have tried going based off each className (this app is built using react) but this does not work. It will take a screenshot of the same buttons over and over. I believe because if page.click has multiple of the same options, it only chooses the first one and many buttons have the same styling classNames.
You could get an array of each element on a page, go through the elements with a for loop determine if it is a button, then click it. Then for each page you'd have to input each url in an array and then use a for loop to go through it.

Apex 5.0: Show a progress bar while Database Action is performed

Implementing a Waitbar or Progressbar
In my Apex 5.0 application I have a SQL Update which is taking very long to process, and I want to implement an indicator to show that it is still running, so that the user won't start the action again.
A progressbar would do the trick, can anyone suggest a way of doing so?
(plugins aren't possible)
Just Change the action of your SUBMIT button to Dyanamic Action
On dynamic action choose ON CLICK as Event .Choose Button for Selection Type and Choose Name of your submit Button to Button
Then on Action, Choose SUBMIT PAGE
Then on Request /Button Name, put your SUBMIT button's Name.
Then set SHOW PROCESSING to YES
Use the JavaScript function apex.sumbit to submit the page and include the showWait option to display the progress bar. Here is an example...
apex.submit({ request:"DELETE", set:{"P1_DEPTNO":10, "P1_EMPNO":5433}, showWait:true});

Can't click button using InternetExplorer.Application

I'm trying to click the "Continue" button programatically using the InternetExplorer.application object on the page "http://www.dallascounty.org/criminalBackgroundSearch/". When I click the button, nothing happens.
Below is my code:
loie = CREATEOBJECT('internetExplorer.application')
loie.Navigate2('http://www.dallascounty.org/criminalBackgroundSearch/')
loie.Visible = .T.
loSubmitButton = loie.Document.getElementsByName('Submit')
loSubmitButton.item[0].Click()
Until about a week ago, the button was clicking with no problem. I realize there is also a capatcha on this page, but even if a manually click the "I am not a robot" box, I still can now programmatically click the "Continue" button on the page. Could somebody please tell me what this site did to their page that is preventing me from programmatically clicking buttons and how to get around it?
I also would like to get passed that captcha programmatically, but that is a separate problem which I will deal with later. However, if anybody has any tips on how to get passed that captha as well, I would be greatful.
Thank you

Is it possible to detect if the user can go back?

Basically, I need to replicate the browser back button on my app (I do not want it, but I need to do it :/)
On durandal, I can navigate back by calling router.navigateBack();. But there is not always a page back (the browser back button get disabled when there is not). So, it is possible to detect if there is a previous page?
I am thinking in creating a simple counter that increments when the user navigate and decrement when it clicks on my "back" button, but I do not now how can I detect the user clicked the browser back button. If there is some way to know that there is not any previous page, it would be nice.
I was able to do this by intercepting the router.on('router:route:activating') event. When the user navigate, I increment a variable, when he goes back (router.navigatingBack will be true even if he clicked on the browser back button!) I decrement it. When it is 0, I disable the go back button.