i am automating a mac application using appium. I am not able to go down the in application page. i have tried couple of ways, didn't succeed.
http://appium.io/docs/en/commands/interactions/mouse/moveto/
when i use above option, i am not able find the element itself, but the element is very much available in page.
String xpath=""/AxApplication[#AxTitle='Learning']/AXWindow/AXScrollArea[#AXDescription='My Learning']/AXList[#AXDescription='My Learning']/AXList[#AXDescription='Added by Me']/AXButton[#contains(name,'See All')]";
Actions action = new Actions(adriver);
WebElement elemnt=adriver.findElement(By.xpath(xpath));
action.moveToElement(elemnt, 500, 900);
action.release();
action.perform();
Please suggest.
I am fairly new with using Selenium in my Ruby script. Basically my script will make a get request to some url and log in. However my script is failing to send the email and log in automatically due to the Google Chrome pop up about insecure content blocked since one of the images on the page is using http and not https.
I was able to run the script successfully months ago however just recently when trying again, it is unable to proceed with logging in so I dont know why it stopped working all of a sudden.
The error that I see in terminal is this. In irb, I can go through each line of code successfully including using Selenium's "send_keys" and "click" to automatically sign in.
[2018-09-26T13:02:55.002527 #14131] INFO -- : [#http://company.com/favicon.ico'. This request has been blocked; the content must be served over HTTPS.">]
web_app.rb:54:in `': Console Errors Found! (Exception)
I tried searching for some solution but have been unsuccessful. There has been some variations of responses to similar problem but not too much luck with getting it to work.
Any feedback on how to fix would be appreciated.
start Chrome manualy and disable the warning - https://www.thewindowsclub.com/disable-insecure-content-warning-chrome
and use the set browser profile, there is my setup:
#BeforeClass
public static void setUpClass() {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\pburgr\\Desktop\\chromedriver\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:\\Users\\pburgr\\AppData\\Local\\Google\\Chrome\\User Data");
driver = new ChromeDriver(options);
driver.manage().window().maximize();}
My Selenium tests use onMouseOver features like
List<WebElement> menuitems = getDriver().findElements(By.tagName("li"));
Actions builder = new Actions(getDriver());
WebElement menu = menuitems.get(2);
getDriver().manage().timeouts().implicitlyWait(Constants.IMPLICITY_WAIT, TimeUnit.SECONDS);
builder.moveToElement(menu).build().perform();
I'm using Firefox driver. Since Firefox updated itself to version 18, my tests stopped working. I know this has to do with native events support - but does not version 18 support native events, or am i able to enable them? If not, is there any replacing implementation to my code?
I'm using selenium java 2.28.0.
For Firefox 18 support we need use selenium webdriver api 2.28.0,jar.
Selenium Java 2.27 mentions that native support for FF17 has been added. However, there has been no mention of support for FF18 in the change logs for 2.28. So its webdriver not supporting native events and not FF18 not supporting native events. You can try downgrading to FF 17 and probably turn off automatic updates for some time.
Rolling back to FF17 is a temporary work around until WebDriver version supports FF18
FF17 Extended Support Release packages -- http://www.mozilla.org/en-US/firefox/organizations/all.html
Note: If you are Mac user, you can simply rename your current FF from 'FireFox' to 'FireFox18' in your applications folder. Install the package from the above URL, which should create a new application called 'FireFox' that will be used by WebDriver.
My hover-over broke with v28. I now use the following hoverOver method with an optional javascript workaround and it seems to work okay.
public void HoverOver(IWebElement elem, bool javascriptWorkaround = true)
{
if (javascriptWorkaround)
{
String code = "var fireOnThis = arguments[0];"
+ "var evObj = document.createEvent('MouseEvents');"
+ "evObj.initEvent( 'mouseover', true, true );"
+ "fireOnThis.dispatchEvent(evObj);";
((IJavaScriptExecutor)driver).ExecuteScript(code, elem);
}
else
{
Actions builder = new Actions(driver);
builder.MoveToElement(elem).Build().Perform();
}
}
I was facing the same issue with Firefox 20. Then I re-installed latest Selenium server (.jar files).
http://selenium.googlecode.com/files/selenium-server-standalone-2.32.0.jar
Hope this works!
I have to test a dynamic app using the ZK framework and Selenium does not identify the id's from the different elements, so can't enter text in the textboxes or select an element in a list (elements from a database)
Whatever I use (xpath or css selector) nothing works, always the same error
Does anyone know how can I fix my problems?
I'm using Selenium IDE 1.9.0
Netbeans IDE 7.1.1
And Firefox 16.0.2
Thanks
The Html code is:
button id="zc_subdossierzulButton_8" class="butt z-button-os" style="border-style: solid;border-width: 1px;border-color: #ED0000;" type="button">Rechercher
And the Java code i tried is:
driver.findElement(By.cssSelector("zc_subdossierzulButton_8.butt"));
don't work
this:
driver.findElement(By.cssSelector("butt z-button-os"));
don't work
and this:
String cssSelector = "[class='butt z-button-os']";
driver.findElement(By.cssSelector(cssSelector)).clear();
driver.findElement(By.cssSelector(cssSelector)).sendKeys("c");
Please go through the following documentation and try using different options like
driver.findElement(By.id("coolestWidgetEvah"));
OR
driver.findElements(By.className("cheese"));
OR
driver.findElement(By.tagName("iframe"));
OR
driver.findElement(By.name("cheese"));
OR
driver.findElement(By.linkText("cheese"));
OR
driver.findElement(By.partialLinkText("cheese"));
OR
driver.findElements(By.xpath("//input"));
http://seleniumhq.org/docs/03_webdriver.html#locating-ui-elements-webelements
I am running several tests with WebDriver and Firefox.
I'm running into a problem with the following command:
WebDriver.get(www.google.com);
With this command, WebDriver blocks till the onload event is fired. While this can normally takes seconds, it can take hours on websites which never finish loading.
What I'd like to do is stop loading the page after a certain timeout, somehow simulating Firefox's stop button.
I first tried execute the following JS code every time that I tried loading a page:
var loadTimeout=setTimeout(\"window.stop();\", 10000);
Unfortunately this doesn't work, probably because :
Because of the order in which scripts are loaded, the stop() method cannot stop the document in which it is contained from loading 1
UPDATE 1: I tried to use SquidProxy in order to add connect and request timeouts, but the problem persisted.
One weird thing that I found today is that one web site that never stopped loading on my machine (FF3.6 - 4.0 and Mac Os 10.6.7) loaded normally on other browsers and/or computers.
UPDATE 2: The problem apparently can be solved by telling Firefox not to load images. hopefully, everything will work after that...
I wish WebDriver had a better Chrome driver in order to use it. Firefox is disappointing me every day!
UPDATE 3: Selenium 2.9 added a new feature to handle cases where the driver appears to hang. This can be used with FirefoxProfile as follows:
FirefoxProfile firefoxProfile = new ProfilesIni().getProfile("web");
firefoxProfile.setPreference("webdriver.load.strategy", "fast");
I'll post whether this works after I try it.
UPDATE 4: at the end none of the above methods worked. I end up "killing" the threads that are taking to long to finish. I am planing to try Ghostdriver which is a Remote WebDriver that uses PhantomJS as back-end. PhantomJS is a headless WebKit scriptable, so i expect not to have the problems of a real browser such as firefox. For people that are not obligate to use firefox(crawling purposes) i will update with the results
UPDATE 5: Time for an update. Using for 5 months the ghostdriver 1.1 instead FirefoxDriver i can say that i am really happy with his performance and stability. I got some cases where we have not the appropriate behaviour but looks like in general ghostdriver is stable enough. So if you need, like me, a browser for crawling/web scraping purposes i recomend you use ghostdriver instead firefox and xvfb which will give you several headaches...
I was able to get around this doing a few things.
First, set a timeout for the webdriver. E.g.,
WebDriver wd;
... initialize wd ...
wd.manage().timeouts().pageLoadTimeout(5000, TimeUnit.MILLISECONDS);
Second, when doing your get, wrap it around a TimeoutException. (I added a UnhandledAlertException catch there just for good measure.) E.g.,
for (int i = 0; i < 10; i++) {
try {
wd.get(url);
break;
} catch (org.openqa.selenium.TimeoutException te) {
((JavascriptExecutor)wd).executeScript("window.stop();");
} catch (UnhandledAlertException uae) {
Alert alert = wd.switchTo().alert();
alert.accept();
}
}
This basically tries to load the page, but if it times out, it forces the page to stop loading via javascript, then tries to get the page again. It might not help in your case, but it definitely helped in mine, particularly when doing a webdriver's getCurrentUrl() command, which can also take too long, have an alert, and require the page to stop loading before you get the url.
I've run into the same problem, and there's no general solution it seems. There is, however, a bug about it in their bug tracking system which you could 'star' to vote for it.
http://code.google.com/p/selenium/issues/detail?id=687
One of the comments on that bug has a workaround which may work for you - Basically, it creates a separate thread which waits for the required time, and then tries to simulate pressing escape in the browser, but that requires the browser window to be frontmost, which may be a problem.
http://code.google.com/p/selenium/issues/detail?id=687#c4
My solution is to use this class:
WebDriverBackedSelenium;
//When creating a new browser:
WebDriver driver = _initBrowser(); //Just returns firefox WebDriver
WebDriverBackedSelenium backedSelenuium =
new WebDriverBackedSelenium(driver,"about:blank");
//This code has to be put where a TimeOut is detected
//I use ExecutorService and Future<?> Object
void onTimeOut()
{
backedSelenuium.runScript("window.stop();");
}
It was a really tedious issue to solve. However, I am wondering why people are complicating it. I just did the following and the problem got resolved (perhaps got supported recently):
driver= webdriver.Firefox()
driver.set_page_load_timeout(5)
driver.get('somewebpage')
It worked for me using Firefox driver (and Chrome driver as well).
One weird thing that i found today is that one web site that never stop loading on my machine (FF3.6 - 4.0 and Mac Os 10.6.7), is stop loading NORMALy in Chrome in my machine and also in another Mac Os and Windows machines of some colleague of mine!
I think the problem is closely related to Firefox bugs. See this blog post for details. Maybe upgrade of FireFox to the latest version will solve your problem. Anyway I wish to see Selenium update that simulates the "stop" button...
Basically I set the browser timeout lower than my selenium hub, and then catch the error. And then stop the browser from loading, then continue the test.
webdriver.manage().timeouts().pageLoadTimeout(55000);
function handleError(err){
console.log(err.stack);
};
return webdriver.get(url).then(null,handleError).then(function () {
return webdriver.executeScript("return window.stop()");
});
Well , the following concept worked with me on Chrome , try the same:
1) Navigate to "about:blank"
2) get element "body"
3) on the elemënt , just Send Keys Ësc
Just in case someone else might be stuck with the same forever loading annoyance, you can use simple add-ons such as Killspinners for Firefox to do the job effortlessly.
Edit : This solution doesn't work if javascript is the problem. Then you could go for a Greasemonkey script such as :
// ==UserScript==
// #name auto kill
// #namespace default
// #description auto kill
// #include *
// #version 1
// #grant none
// ==/UserScript==
function sleep1() {
window.stop();
setTimeout(sleep1, 1500);
}
setTimeout(sleep1, 5000);