Selenium 2 Automation Framework deployed as WAR on tomcat - maven

I have created a selenium 2 automation framework, using maven have packaged it into a WAR file.
After deploying build, when i start am getting my landing jsp, its a simple one, with a button as StartRun, on click of that i have initiated creation of WebDriver instance (am using ChromeDriver) and navigation to a specific URL.
But when i click on the button nothing happens,i have enabled log4j to capture all actions, so from logs i could see ChromeDriver instance is created, but am not able to see Chrome window opening up.
Am using selenium-2.44.0 and language is Java
Here is the piece of code where ChromeDriver instance is created :
System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe");
WebDriver driver = new ChromeDriver();
captureLogs.info("Opening browser");
try {
objectForTest(driver);
}
Any help would be much appreciated, happy to share more details if required.

Related

uploading files to web application using ruby watir web driver

I am trying to upload a txt file to the web application I'm working on, through automation.The application only allows browsing and selecting the file from the local system and it doesn't allow to set the path of the file.Ruby watir-webdriver is the tool used for automating.Can someone help me in automating this.
It looks like this:
file = "/full/path/to/file.jpg"
browser.file_field(id: "upload-here").set(file)

Spring Maven deployed successfully uinsg Intellij to JBoss, but JBoss welcome page is still showing

This is my first ever Spring/maven/JBoss App. Basically, I am trying to follow the instructions here
I am using Intellij 2016.3.5, JBoss EAP 7.0.0
I tried to follow the instructions in the home page. I generated the war file following the steps below:
File => Project Structure
Artifacts => + => Web Application Archive
Create Manifest File which looked empty:
run successfully.
In the output it shows it connected to the server
it opens automatically the web page at http://localhost:8080. But it is still displaying the Jboss's welcome page.
The unnamed.war file is placed in ..\EAP-7.0.0\
At the end of there is the following added automatically:
<deployments>
<deployment name="unnamed.war" runtime-name="unnamed.war">
<fs-archive path="C:\Users\VAIO\EAP-7.0.0\unnamed.war"/>
</deployment>
</deployments>
What could have gone wrong in my steps above?
Update
After #CrazyCoder 's comment, I followed the documentation here, and enabled web Application, where the project modules looks like this now:
and the project structure:
It runs, and opens http://localhost:8080/unnamed/
But it displays the word forbidden now. Am I heading in the wrong direction?
I found the solution based on #CrazyCoder's comment. In a nutshell, I followed the documentation as follows
Download zip from here
Extracted initial folder from here (initial directory contains the project that I started with).
Import initial project to Intellij.
In Intellij, right click on the root project directory, and select Add Framework support .... Then select the Web Application check box in the dialog that opens. What we did here, is to enabling Web Application options as per the documentations here
Verify that Intellij has generated WEB-INF directory under your root project directory, and this directory contains the exploded war file. It does that automatically once you enable your Web Application option. Check here for more details.
Back to Spring tutorial here. Create new class hello/SampleController.java, and modify the pom.xml accordingly.
Intellij will prompt you to import the changes (if you did not enable auto import) to resolve the dependencies you modified in pom.xml. Import the changes
Assuming your JBoss is installed and configured, you do not need to do anything on the web server side. Intellij will handle that for you.
Choose run, then edit configuration, then choose your server (JBoss local in my case)
If all goes well, it will open the browser with empty page (or pages contains $ENDED$, as we did not add any content.
You can add static content to your html page index.jsp in my case, and change the body, and the title, then deploy again to display Hello World
You could eventually bind the returned value from hello/SampleController.java to your index page to display dynamic values.

Selenium profile is getting detected by Google?

Basically I'm trying out Selenium webdriver (using FireFox) and right now I am trying to sign up to a Google account.
However, the strange thing is that whenever I run Selenium and let it use the (empty I assume?) Selenium FireFox profile Google seems to detect it and block me (asking for phone vertification).
This is even the case when I load up the selenium profile and manually sign up.
When I sign up manually (and don't use the selenium profile) I can sign up just fine.
Is the Selenium FireFox profile some how special which enables the servers to detect it?
EDIT: I'm trying to startup selenium with my default FF profile (however it keeps starting up in an empty profile) - here's the code:
OpenQA.Selenium.Proxy proxySetting = new OpenQA.Selenium.Proxy();
proxySetting.HttpProxy = proxy;
proxySetting.FtpProxy = proxy;
proxySetting.SslProxy = proxy;
FirefoxProfile profile = new FirefoxProfile("default");
profile.SetProxyPreferences(proxySetting);
profile.SetPreference("browser.privatebrowsing.autostart", true);
_driver = new FirefoxDriver(profile);
EDIT:
I managed to open the default firefox profile but now it doesn't use my proxy settings. How can I use the normal profile and still customize the profile proxies?
This post talks about an HtmlDriver tag being added to the HTML in the FirefoxDriver which would be a dead giveaway
Google is a strong supporter of Open Source, and even Selenium itself, however I don't think Google would particularly condone a Selenium script creating a bunch of spam accounts that probably would never be used, and just take space.
That being said, I believe that it would be possible potentially.
The only way that Google would be able to know you are using Selenium, is based on the Request Headers. It's possible either the User-Agent has something to do with Selenium, or one of the other Headers.
My solution would be to use something like Fiddler to listen to the requests that Firefox is sending, and then edit your Selenium scripts to account for, and change those requests so Google does not know that you are using Selenium.
This most likely goes against their terms of use, so exercise caution, and use this answer for educational purposes only.
Is there a chance, if you were using the complete path to your firefox profile directory? (e.g. C:\Users\???\AppData\Roaming\Mozilla\Firefox\Profiles\your_profile.default)

Selenium Maven Plugin - Selenese goal missing firefox profile parameter

right I have hit a wall using the Selenium Maven Plugin - using the selenese goal which is all swell - however when it comes to executing the tests in firefox, the plugin launches a fresh firefox profile, which doesn't have the company proxy configured.
Now if i were simply executing my html suite directly with the selenium server jar I could specify a firefox profile - however it appears to be the case this has not been included in as a parameter in the selenese goal for this plugin. madness!
there are such parameters for the start-server goal, so why not selenese?
Has anybody else faced this issue? Any workarounds?
Appreciate all sensible input.
Thanks,
I thought I would post my solution should anyone else come accross this...
Simply need to get the selenium maven plugin source, and patch it. The constants are available in the selenium server RemoteControlConfiguration class however this plugin doesn't make use of them all in the SeleneseMojo. So it is a very simple fix:
Set the properties that we want to change when the seleneseMojo starts the selenium server. So in this case I wanted to make use of firefoxProfileTemplate so I did this:
def conf = new RemoteControlConfiguration()
conf.port = port
conf.singleWindow = !multiWindow
conf.firefoxProfileTemplate = firefoxProfileTemplate
def server = new SeleniumServer(slowResources, conf)
server.start()
Now I can specify a firefoxProfileTemplate value in my maven project execution configurations and therefore specify a firefox profile when running selenium html suites through maven.

Keeping cookies when testing an addon

I'm developing an addon using Firefox Add-on SDK. I am using cfx to run my addons when testing.
The app posts some text when highlighted to twitter.
The problem is each time I modify the code I have to log back into twitter. Is there any way to ensure cookies are saved whilst testing/debugging? Similar to what happens when you open and close Firefox normally?
What are your parameters for calling cfx? By default, cxf executes in a new profile.
You need to use -p PROFILEDIR or --profiledir=PROFILEDIR param to use a specific profile, and associated settings.
From notes # https://jetpack.mozillalabs.com/sdk/1.0b5/docs/dev-guide/addon-development/cfx-tool.html

Resources