w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Find PID of browser process launched by Selenium WebDriver
To get process id and attempt to kill it you would use Process class. The methods of interests are: GetProcessesByName Kill Once you resolve a process by name you can query it's property: process.Id for an id. Keep in mind, some browsers, like Google Chrome have several running processes (Chrome has at least one running process per tab). So if you want to kill it, you need to kill all the processes.

Categories : C#

how to implement a find text in a webpage in selenium webdriver ie using c#?
If you just want to search for some text present, you could implement something like this: boolean isTextPresent(String text){ return driver.getPageSource().contains(text) }

Categories : C#

Find an element by text and get xpath - selenium webdriver junit
The XPath of an element is not a definitive value. An element can be found by many XPaths. You cannot use Webdriver to extract an XPath and even if you could, it is unlikely to be the most efficient or sensible one, that can only be defined by the automator.

Categories : Selenium

Hidden XPATH to find element of text? Ruby-selenium
all your xpaths seems correct to me... I think when you are trying to find the element using your xpath ... the element is not loaded properly... try to use explicit wait. Please try to use the code provided below: wait = Selenium::WebDriver::Wait.new(:timeout => 10) wait.until { driver.find_elements(:xpath, "Any of your above mentioned xpaths") }

Categories : Ruby

Need some plugin to use in selenium for browser compatable( for cross browser UI testing )
Selenium is a browser automation tool. It can only drive the browser by interacting with an HTML page loaded in the browser. There are currently no plugins (and as far as I'm aware nobody has any plans to make any) that you can add to Selenium to enable it to automate the OS level GUI.

Categories : Testing

Browser profile in selenium
This differs slightly from browser to browser. On IE, there are obviously no profiles, so the default one is used. On FF and Chrome (I don't know about Opera), if there's no profile specified, Selenium opens up with a new, clean profile every time. Any new window opened by WebDriver is of course opened via the current profile. Once WebDriver is instantiated, it used the assigned profile. All cookies and sessions behave according to the profile settings.

Categories : Selenium

Selenium Junits on headless browser
Take a look at PhantomJS. It is a headless WebKit-based browser and there is Selenium WebDriver for that called GhostDriver. That's what i use and is OK but there is also the option of using a headed browser like Firefox or Chrome and then use Xvfb to ignore screen output.

Categories : Selenium

can I run selenium 2 on real browser without webdriver?
Selenium 2 uses a "real" browser to execute your tests. The Webdriver is only to control the browsers (e.g. open a page, click on a button). However you also can test it in "remote mode" where no "real" browser is used.

Categories : Java

Access browser logs in Selenium?
You could inject javascript and override the log function (as reading the log is not permitted from JS). See http://tobyho.com/2012/07/27/taking-over-console-log/ for an example and there are many SO questions on this topic. The problem with this is that it still can't get the logs which happened prior to injection. It gets easier if you override this in the test deployment directly.

Categories : Python

selenium c# keeping browser open
In answer to your question, yes and no. Manually closing will not destroy the WebDriver session, but if you subsequently call a method on the object which interacts with the browser (eg FindElement, Navigate, etc. ), an exception will be thrown because the browser no longer exists. What exactly are you trying to do? There may be a better solution.

Categories : C#

Get PID of browser started by Selenium (in java)
Not particularly, you would have get the list of processes currently running and filter it down. There is no special attributes or features that Selenium uses to launch a browser. Therefore, if you are running an instance of that browser that was launched manually, you will get that too. That is to say that if you have two instances of Firefox, one that Selenium launched and is doing it's testing on, and one of your own Firefox sessions, then you are going to have both in the filtered list, there is no way at all to tell them apart. Take a look at this SO question. Use this code to get all currently running processes. Filter it down to the browser you are trying to get. If you explain what you are trying to achieve by doing this, we may be able to give a better answer.

Categories : Selenium

Browser is not launching when i run selenium webdriver
Try to check options of different drivers. The existing drivers are the ChromeDriver, InternetExplorerDriver, FirefoxDriver, OperaDriver and HtmlUnitDriver. For more information about each of these, including their relative strengths and weaknesses, please follow the links to the relevant pages. There is also support for mobile testing via the AndroidDriver, OperaMobileDriver and IPhoneDriver. For Chrome WebDriver you should start a server to be able to communicate with the browser.

Categories : Eclipse

Use Chromium Browser with webdriverjs and Selenium
Following the instructions in this wiki page, I can run chromium browser with selenium using WebDriverJS. You need to download a ChromeDriver and export Path to your system's environment.

Categories : Google Chrome

selenium chrome browser logging in console
I have not used selenium with python but this ruby example might be of some use: Silencing ChromeDriver.exe logging

Categories : Python

How to open specific browser using selenium webdriver
Just specify the path to the binary of the version..may be, like- FirefoxBinary binary = new FirefoxBinary(new File("path_to_bin")); FirefoxProfile profile = new FirefoxProfile(); WebDriver driver = new FirefoxDriver(binary, profile);

Categories : Java

After launching the specified browser with Selenium RC, The test doesn't run
The mistake I made was that my selenium test "BasicTest.html" wasn't a test suite. Since it was a single test, the -html suite didn't recognize it. It only looks for a test suite to execute. I had to put the "BasicTest.html" into a "SeleniumTestSuite.html" and referenced that instead. So the new command looked like this: java -jar selenium-server-standalone-2.35.0.jar -htmlSuite "*googlechrome" "http://www.xxxx.com" "C:UsersTunjiDesktopSeleniumTestsCoreFunctionalitySeleniumTestSuite.html" "C:UsersTunjiDesktopSeleniumTestsCoreFunctionality esults.html" -firefoxProfileTemplate "C:UsersUsernameAppDataRoamingMozillaFirefoxProfilessrebkp2.selenium" After that It ran like it was supposed to :). Hope that's clear enough. Tunji

Categories : Java

Save document in Chrome browser using Selenium
I hope that this is of use to someone. This solution works cross browser and does not rely on setting profiles or preferences in the browser when it is launched. import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Set; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.CookieStore; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.params.ClientPNames; import org.apache.http.client.params.CookiePolicy; import org.apache.http.client.protocol.ClientContext; import org.apache.http.cookie.ClientCookie; import org.apache.http.impl.client.BasicCookieStore; import org.apache.http.impl.client.DefaultHttp

Categories : Java

How to open a new window on a browser using selenium for python?
How about you do something like this driver = webdriver.Firefox() #First FF window second_driver = webdriver.Firefox() #The new window you wanted to open Depending on which window you want to interact with, you send commands accordingly print driver.title #to interact with the first driver print second_driver.title #to interact with the second driver For all down voters: The OP asked for "it is only important that a second instance of the browser is opened.". This answer does not encompass ALL possible requirements of each and everyone's use cases. The other answers below may suit your particular need.

Categories : Python

Python Selenium run multiple tests in one browser instance?
This depends on capabilities of your test runner. Nose test framefowrk allows you to define package level setup methods as well as module, class, and method setups. Another method for manually providing the browser instance from another class is described in this answer to similar question.

Categories : Python

Selenium: Do different browser instances have separate cookie jars?
Selenium (web driver) allows to open several browser windows (e.g. 3 Firefox windows or 1 IE + 1 Firefox +1 Chrome). In you code you have API to select the desired window (depending how on how you opened it). Regarding the session handling: that depends on the browser type. Firefox will share the session across multiple windows because it's using a single process. AFAIK IE and Chrome if opened as new processes will not share it, but this of course depends also on how the server is setting the cookie policy for the session. Access to cookie values in the browser however is domain dependent, so a persistent cookies or local storage can share information even across sessions, so it really depends on how the web application is implemented (or what framework is using - that mostly takes care

Categories : Selenium

Problems with loading chrome browser using selenium web driver
Do not use your Chrome binary that you browse the internet with. Download it from the Chromedriver website, and specify the path to that in your code. This link has the solution explained in more detail: http://www.gjdb.nl/?p=214: When you want to run Chrome on WebDriver for your Mac, then according to according to the site http://code.google.com/p/selenium/wiki/ChromeDriver you will need to specify the path to the browser to the following location: “/Applications/Google Chrome.app/Contents/MacOS/Google Chrome”. So the Java code for creating a ChromeDriver instance will be: System.setProperty("webdriver.chrome.driver", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"); driver = new ChromeDriver(); When trying to run this I got the following exception.

Categories : Java

Selenium IEDriverServer.exe - The browser opens up but .SendKeys() isn't working
Disable protected mode in IE browser and disable it for all four icon 1) Internet 2) trusted 3) Local Intranet 4) restricted site Tools > internet options > security > Enable protected mode Enable protected mode check box, check image

Categories : C#

selenium webdriver ruby clear browser localstorage
This page has some information on how to use JavaScript to modify local storage: https://groups.google.com/forum/?fromgroups#!searchin/selenium-users/html5/selenium-users/qahuzVl1svQ/hR6FO3GGzDMJ. The example is in Java, but the basic idea should work in any language since you ultimately use JavaScript in the browser. this.executeJavascript(String.format("window.localStorage.clear();")); Just tried it with WebDriverJS in Chrome and it seems to work.

Categories : Ruby

Best Way to Reset Browser State in TestNG with Selenium and Java
I believe that calling driver.close() or driver.quit() and then creating a new WebDriver and assigning it to your driver should do the trick. You'd probably want to call the same function to create the driver at both the beginning and end of your class.

Categories : Java

Jenkins running selenium tests without opening browser
nohup runs Jenkins in the background (http://en.wikipedia.org/wiki/Nohup), in which case according to this post Jenkins will start the browser in the background as well. Try starting jenkins without nohup so that it runs in the foreground (java -jar jenkins.war --httpPort=-1 --httpsPort=8082). Or you can start Jenkins as a daemon (this Jenkins Wiki page contains an example of init script). When Jenkins is started as daemon, the browser started by its job is visible.

Categories : Selenium

Selenium running headless Firefox browser in Windows
No, I don't believe Firefox has the ability to run headless. Why would it? If you need a headless browser, people usuall go with PhantomJS . If you want to take it to the next level (with BDD) then you could also look at CasperJS .

Categories : Firefox

Catch JavaScript Errors in Selenium WebDriver – Browser Independent
I don't know of any way to directly catch Javascript code errors by a test framework. If I were to guess, I would use PhantomJS. Or, maybe something like MITM Proxy would work? As a sidenote, if you run Selenium2 Grid Hub with a separate Node, you can pass a Java option to the JVM of the node like this that will allow a proxy through Fiddler to work. Fiddler listens (by default) on port 8888. With this method you can watch packets. :: batch script: Set JAVA_OPTS java options to JVM SET "JAVA_OPTS=-Dwebdriver.chrome.^ driver=%CHROMEDRIVER%" IF "%PROXY_TO_FIDDLER%"=="true" SET "JAVA_OPTS=%JAVA_OPTS% -DproxySet=true^ -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888" I created scripts you can use to start your grid and node here. It seems to me that you could use this method to

Categories : Java

selenium grid: Error communicating with the remote browser. It may have died"
The only time I get that error is when I manually close the browser myself. I would verify that the machine withe the browsers is stable. It could also be due to calling driver.quit() and not instantiating another driver (I haven't ever done this, so I don't know what error this throws)

Categories : Selenium

How to Initialize a C# Selenium webdriver test to pass in different browser types?
Do something like this: WebDriver _webDriver = null; if (Browser == "Firefox") _webDriver = _firefoxDriver; else if (URL == "Chrome") _webDriver = new ChromeDriver(); else if (URL == "IE") _webDriver = new InternetExplorerDriver();

Categories : C#

Browser Simulation and Scraping with windmill or selenium, how many http requests?
Selenium uses the browser but number of HTTP request is not one. There will be multiple HTTP request to the server for JS, CSS and Images (if any) mentioned in the HTML document. If you want to scrape the page with single HTTP request, you need to use scrapers which only gets what is present in the HTML source. If you are using Python, check out BeautifulSoup.

Categories : Python

How to use same browser window for automated test using selenium-webdriver (ruby)?
The Before hook is run before each scenario. This is why a new browser is opened each time. Do the following instead (in the env.rb): require "selenium-webdriver" driver = Selenium::WebDriver.for :ie accept_next_alert = true driver.manage.timeouts.implicit_wait = 30 driver.manage.timeouts.script_timeout = 30 verification_errors = [] Before do @driver = driver end at_exit do driver.close end In this case, a browser will be opened at the start (before any tests). Then each test will grab that browser and continue using it. Note: While it is usually okay to re-use the browser across tests. You should be careful about tests that need to be run in a specific order (ie become dependent). Dependent tests can be hard to debug and maintain.

Categories : Ruby

Can Selenium be run on a server to automate tasks, or does it need a browser to run the task inside of
Selenium always need an instance of a browser to control. Luckily, there are browsers out there that aren't that heavy as the usual browsers you know. You don't have to open IE / Firefox / Chrome / Opera. You can use HtmlUnitDriver which controls HTMLUnit - a headless Java browser that does not have any UI. Or a PhantomJsDriver which drives PhantomJS - another headless browser running on WebKit. Those headless browsers are much less memory-heavy, usually are faster (since they don't have to render anything), they don't require a graphical interface to be available for the computer they run at and are therefore easily usable server-side.

Categories : Selenium

How do i select text from a text field using 'CTRL A ' using selenium webdriver?
Humm.. Look Selenium::WebDriver::Element#text So use : elem = wait.until { element = driver.find_element(:id, 'embed-showembedcode') element if element.displayed? } puts elem.text # => target text will be printed here Now to fix the error,I would suggest you always do some machine representation test as below. It is not needed that Selenium::WebDriver::Keys mentioned mapping will be good to work in your machine: require "selenium-webdriver" puts Selenium::WebDriver::Keys::KEYS # => {:null=>"uE000", :cancel=>"uE001", :help=>"uE002", :backspace=>"uE003", :tab=>"uE004", # :clear=>"uE005", :return=>"uE006",:enter=>"uE007", :shift=>"uE008", # :left_shift=>"uE008", :control=>"uE009",.. } elem = wait.until { element = driver.find_element(:id, 'embed-

Categories : Ruby

Selenium using the old page after browser back button action and not showing alterations to DOM
As my understanding,When back button is clicked it will freshly load the mytestpage1.htm where the generatingResults is hidden.i.e,your previous transaction was not persisted.If you are using any server side scripting, then have someother solutions. For now, try the following. Set a cookie object while moving to next page,then depends the cookie value set the display property of your string while you are coming back. Check here if you are new to Cookies change your searchClick method as follows, function searchClick() { // check your cookie variable whether to display or not use a if condition document.getElementById("generatingResults").style.display = 'block'; location.href = 'mytestpage2.htm'; // if it is the first time you are visiting this page, That is your cook

Categories : C#

Running selenium tests in parallel, not for cross browser, but for speed purposes
Have a look at https://github.com/Ardesco/Selenium-Maven-Template if you check it out and modify the <threads>1</threads> property you will be able to get it to run multiple instances of a browser. The relevant code to set this up is: package com.lazerycode.selenium; import com.opera.core.systems.OperaDriver; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.phantomjs.PhantomJSDriverService; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.o

Categories : Selenium

selenium web driver on windows 7 parallels vm - browser hidden - allow service to interact with desktop?
Unfortunately, this is a common problem with selenium (or any other browser automation software) on Windows. If selenium is running in the background as a service, the browser will not appear when the tests are being run and taking screenshots will just result in a black picture. If you want to be able to watch the tests being run and grab screenshots, the general consensus is to start your script manually from the command line and leave it running.

Categories : Windows

Any way to force Selenium to consider a page fully loaded, even when the browser has unfinished requests pending?
As suggested by Arran, it is best to figure out the reason for page taking time to load. But as a workaround, you can use JSExecutor to do the click operation for page navigations. It still leaves you with an issue if the main landing page also takes time to load.

Categories : Google Chrome

Sikuli, selenium testing on Jenkins: Allow the browser to be launched in the foreground, as it is when i run it from development machine?
So you've got a development machine where Sikuli works, and a test machine where Jenkins runs Sikuli and it doesn't work. I had this same setup (with the Sikuli tester/Jenkins slave running Windows 7). What worked for me was to have the test machine run a VNC server, log in as a the tester account over VNC, and launch the Jenkins slave as a regular application and not a service. I used UltraVNC server. As far as I could tell, the problem stems from Windows' security measures, which are designed to prevent a remote user from controlling your machine without your presence. If you run Jenkins as a service, it doesn't get a real desktop allocated to it. The script will run, but (as you're seeing) Sikuli won't actually be able to find anything because there's nothing for it to look at.

Categories : Selenium

Selenium: Find the base Url
Try this regular expression taken from this answer. String baseUrl; Pattern p = Pattern.compile("^(([a-zA-Z]+://)?[a-zA-Z0-9.-]+\.[a-zA-Z]+(:d+)?/"); Matcher m = p.matcher(str); if (m.matches()) baseUrl = m.group(1);

Categories : C#

How to find a link with selenium?
You say I know some unique information about (substring) the href of the link I want to click on so you can use XPath 1.0 function contains(haystack, needle) (see W3C XPath spec). You also need a // or -- safer -- .// at the beginning of your expression to also select descendant a elements of the context node (root node in your case) further down the document tree, and not only direct children a nodes. This gives us: public void clickOnLink(String sub_hrefText){ String xpath = String.format(".//a[contains(@href, '%s')]",sub_hrefText); browser.findElements(By.xpath(xpath)).get(0).click(); }

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.