These are the steps that my code is running.
I start the chromedriver with the secure shell appt - no issues, it launches the browser and appt correctly
chromeOptions.addExtensions(new File("src/test/resources/win32/browserprofile/Secure-Shell-App_v0.8.43.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
I then navigate using driver get to the chrome URL setup page to send connection data.
driver.get("chrome-extension://pnhechapfaindjhompbnflcldabbghjo/html/nassh.html");
While on this page from the image below, I tried to send keys or click on any of the fields with sendkeys or click and I get the following error.
I have tried multiple ways and im getting the same results: org.openqa.selenium.WebDriverException: unknown error: Cannot set property 'value' of null
Here is my code
//Webdriver
driver.findElement(By.xpath("//*[#id='field-description']")).sendKeys("aabb");
driver.findElement(By.id("field-username")).click();
driver.findElement(By.id("field-username")).sendKeys("useridval");
driver.findElement(By.id("field-hostname")).click();
driver.findElement(By.id("field-hostname")).sendKeys("10.0.0.0");
//JavascriptExecutor
// This will execute JavaScript in your script
((JavascriptExecutor)driver).executeScript("document.getElementById('field-username').value='migsrcrfuser';");
Question: Is this even possible, I see an id and the id is unique; furthermore, I also tried xpath and received the same result. Thoughts
Breift description: Terminal emulator and SSH client.
Secure Shell is an xterm-compatible terminal emulator and stand-alone ssh client for Chrome. It uses Native-Client to connect directly to ssh servers without the need for external proxies.
https://chrome.google.com/webstore/detail/secure-shell-extension/iodihamcpbpeioajjeobimgagajmlibd
Update your ChromeDriver to 2.37 (the latest) from https://sites.google.com/a/chromium.org/chromedriver/downloads
I think that you are using Chrome v65
The issue was frame related. I used this code to identified how many frames and then send keys to the correct frame. phew!
int size = driver.findElements(By.tagName("iframe")).size();
System.out.println(size);
driver.switchTo().frame(1); // Switching the inner Frame with 1 0 for outer fram
driver.findElement(By.xpath("//*[#id='field-description']")).sendKeys("9109");
Related
I am trying to automate test to webrtc application and I'm trying to do it with multiple users. I created a setUp as below.
`
ArrayList<String> prefs = new ArrayList<String>();
prefs.add("--use-fake-device-for-media-stream");
prefs.add("--use-fake-ui-for-media-stream");
System.setProperty("webdriver.chrome.driver", "C:\\....\\resources\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments(prefs);
driver = new ChromeDriver(options);
driver.get("https://......");`
but when I use "--use-fake-ui-for-media-stream", the following remote address appears in the logs of the media server of the app.(I used this to disable the security popup for camera and mic.)
remote address looks like: 79beeb9e-ff01-4e69-906c-5be9cab979e6
when I don't use it, the remote address looks like this: 172.17.x.x
Therefore, I cannot connect to the meeting room, the server refuses the remote address.
When I remove "--use-fake-ui-for-media-stream" and put "--user-data-dir=C:\Users....\Local\Temp\...", I overcome this problem, but this time I can only connect to a single chromedriver on the Jmeter, the other chromedrivers are not working. I integrated testcases to Jmeter with Junit request.
I want to use this code for multiple users but I only could do it for a user or I could not connected.
How can i overcome this problem?
When first ChromeDriver instance is launched the profile directory gets locked and it cannot be re-used by 2nd, 3rd, etc. instance.
You can do something like:
prefs.add("--profile-directory=User" + org.apache.jmeter.threads.JMeterContextService.getContext().getThreadNum());
so each instance will have it's own separate profile folder.
More information:
open multiple chrome profile with selenium
JMeterContextService JavaDoc
How to Use JUnit With JMeter
I'm running all my test suites on Jenkins which is deployed on AWS EC2 instance. There is a scenario where when I click on a button, new small window opens up and I'm doing assertion for the text visible inside the small newly opened window. But my tests are failing when I run using Headless mode. But, same scripts works fine when I run scripts locally without opting for headless browser.
The issue here is the scripts are failing because of headless browser since it's unable to capture text inside small window which has opened after click of button.
This class is extending InitiateDriver class which explained. Below class is trying to fetch text which is visible inside the new window which just opened after clicked on SignInWithGSuiteSSOClick() button.
Here is the code:
// click on a button
GSuiteobject.SignInWithGSuiteSSOClick().click();
String winHandleBefore = driver.getWindowHandle();
// Here trying to capture text inside new window opened up basically gmail window to enter email
String signInHeader = GSuiteobject.GsuiteSignInHeader().getText();
Assert.assertEquals(signInHeader, "Sign in");
GSuiteobject.GsuiteEmail().sendKeys("example#gmail.com");
InitiateDriver.java
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.addArguments("--window-size=1920, 1080");
options.addArguments("--disable-gpu");
driver = new ChromeDriver(options);
The same code works in browser mode but not in headless. But the driver will be initialized but it fails only while capturing text. Please help me out I'm stuck here and unable to execute it on Jenkins as a headless browser.
Headless chrome browser's gmail UI will be different from actual gmail UI(latest). Hence it fails when we run headless chrome for automating gmail login since xpaths will differ. We can validate that by taking Screenshot by running on headless and normal browser.
I suggest to take screenshot using both headless and normal browser. To check on xpaths for headless we can try driver.getPageSource() method.
In my Selenium Tests I need to test a webpage where I use a basic Authen,
Knowing that I am using Chrome Headless Java and Selenium WebDriver.
On my machine 'locally' It works perfectly using driver.get("https://admin:admin#localhost..");
and then
driver.get("https://localhost..") for example.
I know that Chrome doesn't support this function anymore but I managed to make it work based on someone's solution here by passing the first URL with credentials and the second without.
But when I run it on remote (Jenkins) On Linux servers I get the following Error
the configuration of your browser does not accept cookies
. I don't have vision on the servers when I can configure Chrome ..any ideas how to make it work without facing that problem.
I know a lot of people asked that question before, But I didn't find any valide answer for my issue.
try ChromeDriver 2.45 (changelog) or change the location, where it is supposed to save the cookies:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
otherwise (per default) it would create a new temporary directory each time it starts a session.
ChromeOptions options = new ChromeOptions();
//Command line flag for enabling account consistency. The default mode is disabled.
options.addArguments("--account-consistency");
//Chrome that will start logging to a file from startup
options.addArguments("--log-net-log=C:/some_path/resource/log.json");
//Sets the granularity of events to capture in the network log.
options.addArguments("--net-log-capture-mode=IncludeCookiesAndCredentials");
Try this, basically, it saves the logs on startup of chrome browser, then it will set the account consistency. Anywhere from the log, you can debug the issue.
Hello I managed to fix the problem (I forgot to mention that our website is protected by Siteminder) so I did the following following:
1-We inject the USER and the PASSWORD on the URL :
The issue we faced was that the displayed prompt wasn’t part of the page’s HTML and it was hard for us to catch it using Selenium. We managed this by directly injecting the user login and the user password in the URL as follow :
‘https://USERNAME:PASSWORD#basicAuthentURL’
This will launch the Chrome session. Beware, this is only the first step of the process. The user identification have not been performed yet.
2- We create a new cookie :
After launching the URL, we have to manually create a cookie called « SMCHALLENGE » and add it to current session with Selenium, for example in JAVA :
new Cookie("SMCHALLENGE", "YES");
3- Call the URL without the user credencials :
As the SMCHALLENGE cookie is now set, the last step is to call the URL again (https://basicAuthentURL ). The SMCHALLENGE cookie will be deleted once the authentication succeed and a SMSESSION cookie will be generated by Siteminder.
The SMSESSION cookie now allows us to call the application and sucessfully pass Siteminder as if normally logged in (via SSO).
Let me know if you try this out.
I've created a Maven project with 20 tests made with Selenium Webdriver (java). Now, when I want to execute my Maven project, I get sometimes the following error:
Mozilla error
This is due to login every test. So, when I want to run 20 tests, sometimes that error appears and I can't continue my test, so it returns "Failed test" in Selenium Webdriver.
Does anybody know how to fix this problem?
I've tried to put "Thread.sleep(30000);" at the end of every test to give them some time "not to seem a robot", but it doesn't work...
Thanks so much for your help guys!
Here is the Answer to your Question:
The Real Issue:
The URL/Connection with which you are a working if it is Not Secure then whenever you access the URL through Mozilla Firefox 53.0, Firefox will display a lock icon with red strike-through red strikethrough icon in the address bar. Now when URL gets loaded the cursor by default will be positioned on Username field and there will be popup showing a message This connection is not secure. Logins entered here could be compromised. Learn More like this:
Now your script through Selenium enters the username within the Username input field and the Not Secure popup overlays the Password input field.
Next if you try to call the click() or sendKeys() operation in the Password input field the Not Secure popup receives the click and Insecure password warning in Firefox page opens up in the next tab along with Selenium shifting its focus to new tab. Hence test-case starts Failing.
Solution:
In these cases the best solution is:
Create a new Mozilla Firefox Profile. You will find the documentation here. For Example, I have created a Firefox Profile by the name debanjan
Configure the Firefox Profile debanjan to ignore all the UntrustedCertificate issues.
Rerun your Test Script without any issues.
Here is a sample code block to disable insecure_field_warning:
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile testprofile = profile.getProfile("debanjan");
testprofile.setAcceptUntrustedCertificates(true);
testprofile.setAssumeUntrustedCertificateIssuer(true);
testprofile.setPreference("security.insecure_field_warning.contextual.enabled", false);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, testprofile);
dc.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(dc);
driver.manage().window().maximize();
driver.navigate().to("http://demosite.center/wordpress/wp-login.php");
Let me know if this Answers your Question.
I have been using Java Selenium WebDriver along with Appium to perform tests on Mobile environment be it Emulator(Genymotion) or Physical devices (Android). I am using chromedriver, which I am using to perform tests on Web App in Chrome browser. I am looping my cases for multiple sets of data but the application requires a full browser Cookie and all Session data to be deleted before each loop starts.
I tried using driver.Manage().Deleteallcookies(), but it did not work out for me. I read in some threads to try creating a new session of the browser before each loop. So I tried driver.quit() but it ends the chromedriver session and ends the test. I also tried driver.close() but got the same results as driver.quit().
Can any one suggest a way to delete the browser cookies and session data in chrome browser??
My Appium version:1.3.4.1
Chromedriver version:2.3
Device/Emulator i am trying to test on : Nexus5/Samsung Note 3 Android:4.4.4/5.0
You can try using the following to ensure a clear session. Note I never tested that myself. My understanding is that selenium by default create a new session unless you specified something different or load a profile.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
ChromeDriver driver = new ChromeDriver(capabilities);