How to calculate the time interval of promo banner content using selenium web driver
Depends on how the promo-banner is implemented.
Several options:
regularly create a screenshot (and verify them against a ground truth)
get the actual content of the banner (assuming its an image) and verify the URL
query the DOM structure (assuming the promo banner vanishes after a while) and check when the element is gone (or no longer visible)
But without any code from you, or even any idea of how the promo-banner is implemented, this task is hard to solve exactly.
Related
I want to automate a simple task inside Facebook Ads Manager. This task involves setting up a campaign and uploading some ads. It can take a human 30 minutes to do this. However, they're doing the same thing every single time. Often with mistakes. It's something that should be automated. Done without human emotion or mistakes.
Facebook is very sensitive and I don't want it to ban me for the wrong reasons. So I need to feel human. I can take my time between clicks. However, the cursor movement itself needs to feel human. I only need to simulate a real human click for ethical purposes.
Say I get an element I want to move my cursor towards:
WebDriver driver;
// Set file path of chrome driver
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// Create object
ChromeDriver driver = new ChromeDriver(options);
// Go to URL
driver.get("FACEBOOK URL");
// Get element
driver.findElement(By.xpath("//span[contains(text(), 'Setup Campaign')]");
What is the best way to move my cursor towards this element as a real human would?
A real human would first move the mouse. Not just click the element
They would move the mouse/cursor slowly. It could take up to say 500-1000 milliseconds. Certainly not instantly.
They would move the mouse/cursor in a curved fashion. Not just in a 100% straight line. Possibly, in a random fashion? So some elements of randomness may be needed?
I'm quite new to Selenium, so any input would be greatly appreciated.
I am writing my code in Java :)
WebDriver doesn't use an operating system input; it communicates directly with the browser via http protocol. If you want to simulate communication like a 'real' mouse input you have to use an automation solution that uses operating system based frameworks. In case of Windows you can use e.g.:
https://github.com/FlaUI/FlaUI (read https://github.com/FlaUI/FlaUI/wiki/FAQ to get the knowledge how to configure Chrome to expose web controls for FlaUI)
https://github.com/microsoft/WinAppDriver
I understand that this is not exactly what you asked, but in this case I recommend you to use the Facebook API instead of selenium.
It's more stable than your approach and without the risk of getting banned.
https://developers.facebook.com/docs/marketing-api/reference/v12.0
I want to make and app with widget to present some data,and i want to be sure it will not become a battery drain source and add all the checks i have to,so there is no problem.
So android documentation actually says that ACTION_APPWIDGET_UPDATE may be sent in response to a new instance for this AppWidget provider having been instantiated, the requested update interval having lapsed, or the system booting.
But i came into this bizarre answer here
Android widget update called twice after device boot
that suggest that the home screen can actually update your widget n times at will.Seems bizarre,and i cant find something similar,do i really have no control over this?
As in the previous answer you found, there is no way to limit how many times the home screen might update the widget - it is responsibility of the homescreen and you cannot control this.
You could add a limit in your update implementation instead. For example, record the time the checks are made. If the widget update is requested again too soon after the last one, ignore it until the required amount of time passes.
My AUT has many pages. I've written test cases for all pages by creating a separate class for each page.
I want to check Responsive UI of all the pages for following resolutions (marked with a red line in image):
My doubts are:
How should I define these resolutions in the script? (Target is to check the responsiveness with aforementioned resolutions only)
How should I define the exact location of certain elements if the resolution is changed? (Currently, it is noticed that element's position mess in different resolutions)
If you want to modify your browser size in Selenium so that it matches a specific resolution you can do driver.manage().window().setSize(new Dimension(1024, 768))
Could you be more clear about your question. We can verify two things while verifying a responsive website
a) Whether the functionality is as expected even when resolution is less. I think locators should not change in this case and should be able to run your existing test cases
b) whether the UI elements are placed in expected positions when resolution is changed. In this case scope is limited and challenging
I'm a java beginner and I'm trying to program a robot that will fill a very annoying form for me.
Why is this form annoyin? Imagine I have to insert a thousand different values into this form but it only lets me insert one value at a time. Everytime time I insert each value I have to press an "OK" button and wait for the URL to update (this takes from 1 to 50s) and only so I'm able to insert another one.
To solve the problem I made a robot that uses a 1min delay between each "OK", but this is far from optimal, since when the URL updates in 1s the robot stays useless for a minute. Even worst, if the url takes more than 1min to update my robot is going to fill the form wrongly.
Is there anything I can do to detect when the url has updated and then use this information as the delay to my robot?
Thanks a lot!
One thing you could try is
Robot.getPixelColor(x,y)
which returns the color of a pixel on the screen. You can tell the robot to wait until the pixel is colored "correctly" (which would happen when the page is completely loaded).
You can use Selenium. It provides a good API and lots of tools for you to automate browser work. Some people might argue that this is not the purpose of the library, but I think that in your case it should work. Link: http://www.seleniumhq.org/download/
Why I think this is the solution:
Selenium is a suite of tools specifically for automating web browsers.
Which seems to be just what you are requesting.
P.S. There are third party drivers as well. For instance, you can download a driver for the Chrome browser.
I'm using Marthon to run tests on a Java Swing application. I build the base tests by recording, then just make small modifications to the resulting Ruby tests to tweak it to fit what I need. I've run into an interesting problem where comboboxes selections do not work. For example, it'll record...
select("Value", "0.25")
...for the Value combobox, which has a valid option of 0.25 in it. However, during playback, the script pauses execution at that point. If I manually click on the combobox (just to drop it down, not actually selecting anything), then the script will select the right number and continue on.
The problem exists for ALL (so far tested) comboboxes in my application, but none of the other control types. Is there a way to select a value in the combobox that works? I don't mind tweaking the recorded script, I just want to not have to manually click on all my comboboxes each time they're in the script!
Have a look at the object map files for the window and change the recognition properties. That should make this consistent.
The _2 basically means that Marathon is unable to find unique properties to identify the components.
Well, I figured it out already... Apparently the recorder just does a poor job at figuring out the correct label for comboboxes. I was able to get some to work by removing the "_2" or whatever at the end. Others, it took incrementing that number. So, apparently the way the recorder sees the screen layout is different from what the player sees.
edit
The newest version of Marathon appears to have fixed whatever was ailing it before. I'm now unable to duplicate the problem.