I am using selenium RC version-2.21. Everything was working fine with
old google chrome. Then it gets auto updated. The problem is when i
run the test cases only the command window(the window where you can
see which command is getting executed) is visible.The second
window(AUT) is not visible.
My google chrome version is 18.0.1025.162 m. Please help with this
issue.
Any time Chrome gets updated, you may need a new version of the "chromedriver" interface to it. That's supplied by the Chrome folks, not by the Selenium folks. Go to http://code.google.com/p/chromedriver/downloads/list and find the one that matches your browser.
The solution is to add a sentence to maximize the AUT window.
You have to add:
seleniumClient.windowMaximize();
after starting your selenium client instance.
Do you get an error message? Or is the browser just not visible (I assume you mean at all and not that it is just minimized?).
As Selenium RC's documentation suggests, not all browser versions are supported (which clearly sucks in this case for you! =[) so you may have to look at Selenium WebDriver, or wait for a new release of Selenium RC to handle the new Chrome. Sorry this doesn't really solve anything for you!
Related
I am trying to access a website that requires a login thru an alert box such as the one below:
I have tried to look up many different ways to do this and they dont seem to work. what i have tried are listed below:
Didnt work and gave me the same login alert.
start_url = 'http://username:password#example.com'
agent.get(start_url)
Keep getting an error message saying "NoAlertPresentException: Message: no alert open"
start_url = 'http://www.example.com'
alert = agent.switch_to_alert()
alert.send_keys("username")
alert.send_keys("password")
Get an error saying webdriver has no attribute "switchTo"
start_url = 'http://www.example.com'
agent.switchTo().alert().sendKeys("username")
I have to use Chrome because of the versions of IE and Firefox I have and can get, do not support the functions in the site
I have been having this exact same issue for some time now - with my end goal being to do this headless (in the background without visually launching an instance of Chromedriver).
Non-Ideal Solution 1:
I first used a library called pynput to automatically type the credentials in to the alert box and click the ok button, it was pretty simple to get working but:
still didn't work headlessly
I had to be focused on the browser or it would type the credentials elsewhere
This worked great in the meantime as everywhere I looked online it seemed like there was nothing I could do to overcome authentication alerts headlessly...
I'm a relative beginner (started programming <1 year ago) so perhaps I just wasn't looking in the right places!
I've now solved this issue though like so:
First I logged in to the alert as normal on Chrome while monitoring the Network section of devtools to get a good look at the GET request for the protected page screencap here:
Upon seeing that the Authorization was Basic (this will work for Bearer too) I tested just copying the same request in Postman with this header and it worked! Now if only there was a way to make http requests from Selenium???
I first tried the library selenium-requests (which didn't work for me: I got the same error as this person https://github.com/cryzed/Selenium-Requests/issues/33
This library seems absolutely excellent and exactly what I needed, I just don't currently have the know-how to get past firewalls/whatever was stopping me at this stage...
What eventually worked for me was the library selenium-wire. I followed this guide https://pypi.org/project/selenium-wire/#intercepting-requests-and-responses to have the webdriver navigate to the protected page as normal, but intercept the request and add the Authorization header before sending it :) now this works for me totally headlessly. Granted, this won't work on more secure websites but I hope it helps someone having the same issue.
This is Pythoncode
Problem with alert boxes (especially sweet-alerts is that they have a
delay and Selenium is pretty much too fast)
An Option that worked for me is: (just exchange the button click in the end with whatever action you want to have)
while True:
try:
driver.find_element_by_xpath('//div[#class="sweet-alert showSweetAlert visible"]')
break
except:
wait = WebDriverWait(driver, 1000)
confirm_button = driver.find_element_by_xpath('//button[#class="confirm"]')
confirm_button.click()
Note to 2: Here is probably the error due to the alert taking more time to load than the single elements (such as username, etc.)
Note to 3.: I think it should be switch_to
Today the picture function on my Glass app stopped working. It was fine yesterday, but now it gets stuck on the Tap to Accept Picture. I think it may have something to do with the new (to me at least) way it handles pictures as well as the viewfinder. What I can find on the glass developers site is deprecated and doesn't work. My hope/belief is that the new idea is for the intent to go to the viewfinder and then take the picture. I'd prefer to still use the glass method, but I am aware of the android API camera method. Here's the code
startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), REQUEST_PIC);
and in onActivityResult
switch(requestCode)
{
case REQUEST_PIC:
String picturePath = data.getStringExtra(Intents.EXTRA_PICTURE_FILE_PATH);
processPictureWhenReady(picturePath);
break;
}
I have got the same problem since upgraded to XE18.3. Instead of spending time to look for a workaround, I've implemented the preview mode with SurfaceView. You could access the camera directly with Camera.Open(), the sample codes can be found at: (search for "camerasample.zip" in the page)
https://code.google.com/p/google-glass-api/issues/detail?id=351
Hope this helps.
This is a problem being experienced after the XE18.3 update. It has been logged in the google-glass-api issue tracker here.
You can try downgrading the firmware as mentioned in the comments, but be sure to note that doing that voids your warranty.
I have the same issue happening to me as well, however if you plug Glass into your computer that is running Eclipse and the adb is running the Intent will complete successfully. This is not a solution but hopefully it'll keep you from getting behind in work until there is an answer available.
we are running into a scenario (both with the latest drop and built from source) with devstudio when restarting eclipse. Initially, we are able to both import as well as define an API fine, both with the graphical editor as well as view source. When we restart eclipse, an exception is displayed (below). Any help greatly appreciated:
java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.acquire(TransactionalEditingDomainImpl.java:576)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.activate(TransactionalEditingDomainImpl.java:508)
at org.eclipse.emf.transaction.impl.TransactionImpl.start(TransactionImpl.java:204)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.createTransaction(WorkspaceCommandStackImpl.java:380)
at org.eclipse.emf.workspace.EMFCommandOperation.createTransaction(EMFCommandOperation.java:215)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:147)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
at org.wso2.developerstudio.eclipse.gmf.esb.diagram.custom.AbstractMediatorFlowCompartmentEditPart.addInSequenceInputConnector(AbstractMediatorFlowCompartmentEditPart.java:76)
at org.wso2.developerstudio.eclipse.gmf.esb.diagram.custom.AbstractMediatorFlowCompartmentEditPart.addChild(AbstractMediatorFlowCompartmentEditPart.java:135)
at org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts.MediatorFlowMediatorFlowCompartment2EditPart.addChild(MediatorFlowMediatorFlowCompartment2EditPart.java:86)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:781)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:726)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$3(GraphicalEditPart.java:1)
We have fixed this problem in the latest Developer Studio 3.5.0 Alpha 4 version. Please download it from [1] and try the same scenario with the new version.
Thanks a lot for reporting the issue to us. It helps us to improve the editor a lot!!
[1]. http://builder1.us1.wso2.org/~developerstudio/developer-studio/3.5.0/Alpha4/
Thanks and Regards,
Harshana
I am coding one project, which needs to launch some webbrowsers with the given url.
I saw some QT examples, but they explained how to launch the default browser, not a particular browser.
Any helping suggestions will be appreciated.
Edit1:
Below is the code I use currently
QString temp="C:/Program Files/Internet Explorer/iexplore.exe";
process->start(temp.toStdString().c_str());
Edit2
Hi, I found that the problem is not in QProcess->start, Because it works perfectly for "explorer.exe", But not works, for executables which are in Program Files.
So I post a new question about it.
If you know which browser you want to start and where they are located on the system (such as the default installation directories). You should be able to use QProcess
This can usually be done as the following:
iexplore.exe http://www.locationOfUrl.com
or
//path/to/app/firefox.exe http://www.locationOfUrl.com
system("/path/to/the/browser \"http://www.the.com/url\"");
or spawn instead of system (gives you control over environment variables, etc.)
I'm trying to test the happy-path for a piece of code which takes a long time to respond, and then begins writing a file to the response output stream, which prompts a download dialog in browsers.
The problem is that this process has failed in the past, throwing an exception after this long amount of work. Is there a way in selenium to wait-for-download or equivalent?
I could throw in a Thread.sleep, but that would be inaccurate and unnecessarily slow down the test run.
What should I do, here?
I had the same problem. I invented something to solve the problem. A tempt file is created by Python with '.part' extension. So, if still we have the temp, python can wait for 10 second and check again if the file is downloaded or not yet.
while True:
if os.path.isfile('ts.csv.part'):
sleep(10)
elif os.path.isfile('ts.csv'):
break
else:
sleep(10)
driver.close()
So you have two problems here:
You need to cause the browser to download the file
You need to measure when the downloaded file is complete
Neither problemc an be directly solved by Selenium (yet - 2.0 may help), but both are solvable problems. The first problem can be solved by GUI automation toolkits, such as AutoIT. But they can also be solved by simply sending an automated keypress at the OS level that simulates the enter key (works for Firefox, a little harder on some versions of Chrome and Safari). If you're using Java, you can use Robot to do that. Other languages have similar toolkits to do such a thing.
The second issue is probably best solved with some sort of proxy solution. For example, if your browser was configured to go through a proxy and that proxy had an API, you could query the proxy with that API to ask when network activity had ended.
That's what we do at http://browsermob.com, which is a a startup I founded that uses Selenium to do load testing. We've released some of the proxy code as open source, available at http://browsermob.com/tools.
But two problems still persist:
You need to configure the browser to use the proxy. In Selenium 2 this is easier, but it's possible to do it with Selenium 1 as well. The key is just making sure that your browser launcher brings up the browser with the right profile/settings.
There currently is no API for BrowserMob proxy to tell you when network traffic has stopped! This is a big hole in the concept of the project that I want to fix as soon as I get the time. However, if you're keen to help out, join the Google Group and I can definitely point you in the right direction.
Hope that helps you identify your various options. Best of luck!
This is Chrome-testing-only solution for controlling the downloads with javascript..
Using WebDriver (Selenium2) it can be done within Chrome's chrome:// which is HTML/CSS/Javascript:
driver.get( "chrome://downloads/" );
waitElement( By.CssSelector("#downloads-summary-text") );
// next javascript snippet cancels the last/current download
// if your test ends in file attachment downloading
// you'll very likely need this if you more re-instantiated tests left
((JavascriptExecutor)driver).executeScript("downloads.downloads_[0].cancel_();");
There are other Download.prototype.functions in "chrome://downloads/downloads.js"
This suites you if you just need to test some info note eg. caused by file attachment starting activity, and not the file itself.
Naturally you need to control step 1. - mentioned by Patrick above - and by this you control step 2. FOR THE TEST, not for the functionality of actual file download completion / cancel.
See also : Javascript: Cancel/Stop Image Requests which is relating to Browser stopping.
This falls under the "things that can't be automated" category. Selenium is built with JavaScipt and due to JavaScript sandbox restrictions it can't access downloads.
Selenium 2 might be able to do this once Alerts/Prompts have been implemented but that this won't happen for the next little while yet.
If you want to check for the download dialog, try with AutoIt. I use that for uploading and downloading the files. Using AutoIt with Se RC is easier.
def file_downloaded?(file)
while File.file?(file) == false
p "File downloading in progress..."
sleep 1
end
end
*Ruby Syntax