I have a java web application in which i have integrated some selenium code which basically does the following job :
I have a login page with user name and password,so once i fill the details and click on login button, it gives call to the selenium code(java method through servlet),which opens another tab and fills the URL and the same details there on its login page.
This works fine with one system.but i have to deploy the .war file in tomcat so that this should work for all the users in same way, but when i am accessing the URL from remote system and logging in ,its opening the browser on my server where my Apache is running.
So my question is how can i achieve this ? if any user access my URL and login it should open another tab in his system rather than on server.
I have tried using grid2, created a hub on server and node on remote system but still when i run my application it opens browser in server.
I am not sure how can i achieve this.
there is one link i found which uses java script in chrome with node.js
[http://aboutcode.net/2013/12/02/automating-chrome-on-windows-with-javascript-using-selenium-webdriverjs.html][1]
How can i execute selenium java script code in java.
Any help will be really appreciated thank you.
This sounds like a gross misuse of the Selenium TEST framework & I urge you to rethink your approach. You can achieve everything you want to with javascript from within YOUR application, passing variables via the querystring to the new window See JavaScript: location.href to open in new window/tab?
Finally able to fix the issue with grid 2
String nodeUrl = "http://"+ip+":5560/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
driver = new RemoteWebDriver(new URL(nodeUrl),capability);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);
To open browser on the client end,we need to pass the IP of that client from javascript to the server.
And driver and selenium should be registered an running before executing the code.
Special Thanks to Manu..
:)
Related
I am really new to android and I am building an app that will take the username and password of a website(https://lms.mrt.ac.lk).
When the user hits the login button of my android app, the app should itself logged in to the above website and retrieve the complete(including js generated html) html source code.
As a start I tried to print the html source code in the android studio. I tried to use HtmlUnit, but later I found that it is not supported by android. Then, I tried to use Selenium on android, but when tried to build the project it gave me an error "More than one file was found with OS independent path 'META INF' ".
And then tries android's WebView to do the thing, as described in this question, but I don't know how to view the complete html output.
So, my question is -
How to login to a website inside an android app
How to get the complete html source code of the logged in website in android(scraping the js)
I want to do the above in same app. I searched everywhere and still could not find anything complete, that helps a beginner.
Please help me! your suggestions/solutions are highly appreciated.
I'll answer your questions in order.
I don't know what javascript android framework you are using, but the solution should be similar to the java solution. For your specific website, the login endpoint is https://lms.mrt.ac.lk/login.php. You should send a POST request to the endpoint with header parameters LearnOrgUsername and LearnOrgPassword. On success, this should return your desired LoginSessionCookies.
Instead of trying to interpret the javascript stuff, you should rather try to understand how the javascript code retrieves the information you need. And then directly access your information by a web request.
I have a windows form application which opens up from a web browser using uri protocol scheme.
I want to check if this windows form application is first installed on the user machine. Is there any way using javascript or jquery to check if the specific application is installed on the user machine first, and based on the installation show either the launch button or a download button.
I know that reading application exe from browser is not good from security standpoint, but if I am able to get this, I can show appropriate message to the user.
So any ways to find out using client side code, or reading specific registry based on my msi package application id saved in registry from client side or is it even recommended to have such a code in place?
Any advice or suggestions would be great.
Thanks in advance!
Checking exe file path can help.
If System.IO.File.Exists("C:\Program Files\notepad.exe") = True then
Msgbox "exe exist"
end if
Make your win forms application write some registry entries upon installation, something like the exe file location. then check for the those entries and decide to start the download URI or the launch URL browser.
I am working on one Automation project using selenium and java and our application is single page application type, So
I have one requirement like I need to extract the Http or Https Request URL from the browser when I click on Submit button.I need to use that URL in my further automation.
I can able to see that URL in Developer tools network tab, But Am unable to get it.
Could you please anyone help me in this.
Suppose there is a website which calls ajax requests everytime however I can't find(or see) any related URL in page source. But I can see every request or ajax calls in network tab using developer tools.
Please refer screenshot I attached to find URL in network tab. Let's say Google analytics link. How can I search the same URL using javascript or any programming language instead of opening network tab or any developer tool?
I want to see that request URL using programming language. I would prefer javascript if there is. Is it possible or any API available to find the usage of requested links?
I would appreciate if it is possible to get it done using Python, Javascript, Java or PHP.
HELP WOULD BE APPRECIATED!
You can use a browser automation tool like Selenium.
Try this python code.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("yourwebsiteurl here")
driver.implicitly_wait(10)
ajax_urls = driver.execute_script("return performance.getEntries().map(entry => entry.name)")
for url in ajax_urls:
print(url)
I have the dynatrace js agent piece of code and i am trying to inject that minified piece of code into the browser instances that pop up on when the protractor tests are running on the selenium grid.
The reason that this is not automatically injected is the fact that they are running on a docker container. What would be the best way to do a manual injection of the code in this case?
I tried doing this:
var dtagent = require('./dtagent-test.js');
browser.driver.executeScript("dtagent");
dtagent contains the minifed dynatrace code that needs to be injected.
but that did not work and it complained that window is not defined.
Any idea how this can work?
Thanks!
I assume this is the Dynatrace JavaScript Agent for UEM (=User Experience Management)? Correct? If that is the case - you need to make sure that you have a Dynatrace Web Server or Java Agent installed on your web/appp server. Why? Because this JavaScript file will be delivered from the dynatrace agent on the server. ALSO - the javascript file will capture data in the browser and POST it back to your web/app server. This also requires the Dynatrace Agent installed on your web/app server.
So - whether you do manual or automatic injection - you have to have the dynatrace agent installed on your server side
Andi
To understand more about the issue, need some information :
You using On-Premise (in home hosted Dynatrace Server) or Saas Portal hosted Dynatrace .
'./dtagent-test.js' is actually referring where:
a. If using SAAS portal, then the proper url mentioned or not?
b. If using On-Premise, then as Andi described that the respective Agent has been configured and the Dynatrace Collector is getting connected properly.
Let us know more so that we can drill down and help you. :)