Im using Appuim+ Selenium Webdriver.
My App is build in Sencha FrameWork so that some of the elements can not be found using Appium Inspector.
So I tried with HTML Xpath, but it gives "element not found exception".
Im pasting the code below:
wd.findElement(By.xpath("//*[#id='DashBoardView_cityInsightsItemId']/div/div/div[2]/div[1]/div")).click();
Err in Console is:
*exceptionorg.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.52 seconds For documentation on this
error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html Build info:
version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:15:17'
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5',
java.version: '1.8.0_73' Driver info:
org.openqa.selenium.remote.RemoteWebDriver Capabilities [] Session
ID: 4c466315-67c5-409e-9ffc-1f0d26c134c4
Element info: {Using=xpath, value=//[#id='DashBoardView_cityInsightsItemId']/div/div/div[2]/div[1]/div}*
HTML Code:
<div class="x-container dashboard_item_cls x-layout-box-item x-stretched" id="DashBoardView_cityInsightsItemId" style=""><div class="x-inner x-vertical x-align-center x-pack-center x-layout-box" id="ext-element-125"><div class="x-img x-img-image x-paint-monitored x-size-monitored dashboard_icon_cls cityInsights_icon_cls x-img-background x-layout-box-item x-stretched" id="ext-image-3"><div class="x-paint-monitor cssanimation"></div><div class="x-size-monitors overflowchanged"><div class="expand"><div style="width: 68.1875px; height: 68.1875px;"></div></div><div class="shrink"><div style="width:
67.1875px; height: 67.1875px;"></div></div></div></div></div></div>
I want to find this element:
<div style="width: 68.1875px; height: 68.1875px;"></div>
Why do I get this error and how do I solve it?
Related
I am trying to automate a scenario in an android application using appium, java. I need to scroll down to an element on the screen to enter a text value. I'm initializing the elements using page factory as shown below.
#AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"com.call4site.handymanservices:id/email\"))")
private WebElement txt_email;
I'm getting a strange error in console as below.
org.openqa.selenium.InvalidSelectorException:
Unsupported CSS selector '*[name='txt_email']'. Reason: 'Error: 'name' is not a valid attribute. Supported attributes are 'checkable, checked, clickable, enabled, focusable, focused, long-clickable, scrollable, selected, index, instance, description, resource-id, text, class-name, package-name''
For documentation on this error, please visit: https://selenium.dev/exceptions/#invalid_selector_exception
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [da3c259c-cf9d-4457-967a-060eadf5f643, findElement {using=css selector, value=*[name='txt_email']}]
Capabilities {appium:app: C:\Users\laksh\Downloads\ha..., appium:appPackage: com.call4site.handymanservices, appium:automationName: uiautomator2, appium:databaseEnabled: false, appium:
desired: {app: C:\Users\laksh\Downloads\ha..., automationName: uiautomator2, deviceName: Android Emulator, platformName: android, platformVersion: 11.0, udid: emulator-5554}, appium:de
viceApiLevel: 30, appium:deviceManufacturer: unknown, appium:deviceModel: Android SDK built for x86, appium:deviceName: emulator-5554, appium:deviceScreenDensity: 560, appium:deviceScr
eenSize: 1440x2560, appium:deviceUDID: emulator-5554, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:pixelRatio: 3.
5, appium:platformVersion: 11, appium:statBarHeight: 84, appium:takesScreenshot: true, appium:udid: emulator-5554, appium:viewportRect: {height: 2308, left: 0, top: 84, width: 1440}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: ANDROID}
Session ID: da3c259c-cf9d-4457-967a-060eadf5f643
at tests.signUpTests.signUpAsNewUser(signUpTests.java:32)
But if I use the following code to initialize the element, then I'm able to scroll down and enter text to it. Has anyone faced this issue?
WebElement txt_email = driver.findElement(AppiumBy.androidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"com.call4site.handymanservices:id/email\"))"));
I have script to login to a site and then waiting for home button to get loaded. I have put fluentwait to wait for element to be visible. But WebDriver is not waiting and failing immediately as the home button is not loaded.
I have tried with fluentwait and webdriverwait but none of them are working.
Here is code I am trying.
By usernameInput = By.name("User”);
By passwordInput = By.name("Password”);
By loginButton = By.xpath("//input[#value='Sign In']”);
String URL = “https://demotest.mytest.com/"
WebDriver driver = new SafariDriver();
driver.get(URL);
driver.manage().window().maximize();
setText(usernameInput,”User1");
setText(passwordInput,”User1");
clickOnElement(loginButton);
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[#title='Home']")));
Throws below error -
org.openqa.selenium.WebDriverException:
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'cnparmar-mac', ip: '10.168.104.60', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_211'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 12.1.1, javascriptEnabled: true, platform: MAC, platformName: MAC, safari:automaticInspection: false, safari:automaticProfiling: false, safari:diagnose: false, setWindowRect: true, strictFileInteractability: false, webkit:WebRTC: {DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false}}
Session ID: 1257BF8B-335E-4E80-8B08-CB15A77AD648
*** Element info: {Using=xpath, value=//div[#title='Home']}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructo rAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCo nstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException( W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpRes ponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpRes ponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExec utor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(Drive rCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.jav a:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver .java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWe bDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver .java:315)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedCond itions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedCond itions.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
at sample.Sample.loginAs(Sample.java:64)
at sample.Sample.test1(Sample.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j ava:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess orImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocati onHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorke r.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Ideally it should wait for Home button to get visible. but it is failing. This works on Chrome,Firefox, IE, Edge on Windows but only failing on Safari on MAC.
It looks like you are mixing up WebDriverWait and FluentWait classes.
Try using the following instead:
WebDriverWait wait = new WebDriverWait(driver, 15, 100);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[#title='Home']")));
I'm working on a project to begin testing Node/Angular applications using Protractor and Jasmine. I have a POC working in most browsers but having a lot of trouble with MS Edge. Here's my environment:
OS: Windows 10 Pro (Version 1709, OS Build 16299.98)
Edge: 41.16299.15.0
EdgeHTML: 16.16299
MS Web Driver: 10.0.16299.15
Node: 6.12.0
Protractor: 5.2.1
Jasmine: 2.8.0
Selenium: 3.8.1
When I run the tests in Chrome, Firefox, and IE (11) the behavior is fine (tests run with expected results). However, with MS Edge the process fails before the test spec can even run.
Example code/output use the Protractor tutorial but I have the same issue when working with our application.
Working conf.js (for Chrome and Firefox)
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['./spec/spec.js'],
multiCapabilities: [
{ 'browserName': 'chrome' },
{ 'browserName': 'firefox', 'marionette': true, 'firefox_binary': "C:\\Program Files\\Mozilla Firefox\\firefox.exe" }//,
]
}
Failing conf.js (for MS Edge)
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:17556',
specs: ['./spec/spec.js'],
capabilites: { browserName: 'MicrosoftEdge' }
}
spec.js
// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
When I run the test for MS Edge after starting the Microsoft Web Driver the following occurs:
$ protractor conf.js
[14:14:18] I/launcher - Running 1 instances of WebDriver
[14:14:18] I/hosted - Using the selenium server at http://localhost:17556
[14:14:20] E/launcher - Error code: 135
[14:14:20] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:17556
[14:14:20] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:17556
at ClientRequest.<anonymous> (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:238:15)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:761:15)
at createDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:626:16)
at Hosted.getNewDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:53:33)
at Runner.createBrowser (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
[14:14:20] E/launcher - Process exited with error code 135
The problem seems to be somewhere around that it says it is using the server on 'localhost' but then makes requests on '127.0.0.1' instead. In theory, they are the same. But in operation, only 'localhost' is responsive. If I try to access 127.0.0.1:17556 it doesn't respond.
This website could not be found
Error Code: INET_E_RESOURCE_NOT_FOUND
I've been looking around a long time (here, SQA, and, the Protactor discussions on GitHub) for info on this but have not found a resolution. Some discussion on GitHub indicates MS Edge testing with Protractor was working at one point. Has anyone been able to successfully run Protractor tests with this version of MS Edge and MS Webdriver?
One final bit of info: I have access to another Windows 10 machine that has an older version of Edge (10240). On that machine I don't have this problem (localhost vs 127.0.0.1), but, it is old enough to still have issues with async and I'm not able to use it for testing with Protractor.
Thanks!
UPDATE
The spec file has not changed but I have updated the config file (conf.js):
// conf.js
exports.config = {
directConnect: false,
framework: 'jasmine',
specs: ['./spec/spec.js'],
seleniumAddress: 'http://localhost:4444/wd/hub',
multiCapabilities: [
//{ 'browserName': 'chrome' },
//{ 'browserName': 'firefox', 'marionette': true, 'firefox_binary': "C:\\Program Files\\Mozilla Firefox\\firefox.exe" },
{ 'browserName': 'MicrosoftEdge' }
]
};
When enabled Chrome and Firefox are able to run the test.
Edge fails with the following (timeout waiting for driver server to start):
$ protractor conf.js
[13:13:53] I/launcher - Running 1 instances of WebDriver
[13:13:53] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[13:14:13] E/launcher - Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'QA-01', ip: '10.1.1.80', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9.0.1'
Driver info: driver.version: unknown
[13:14:13] E/launcher - WebDriverError: Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'QA-01', ip: '10.1.1.80', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9.0.1'
Driver info: driver.version: unknown
at WebDriverError (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at Object.checkLegacyResponse (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at createDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:635:14)
at Hosted.getNewDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:53:33)
at Runner.createBrowser (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
[13:14:13] E/launcher - Process exited with error code 199
As before - the same setup on an older version of Windows 10, Edge (10240), and, the Edge Driver do try to run the tests (albeit with the async execution issue).
This setup is probably better than what I used before but the overall outcome is the same. Protractor tests (on this machine) aren't running in MS Edge (16299).
Any insight or advice is much appreciated.
Thanks!
From what I can gather you need to tell protractor where to find the Edge driver. I found a few blog posts that mention adding seleniumArgs to the config.
seleniumArgs: ['-Dwebdriver.edge.driver=your/path/to/MicrosoftWebDriver.exe']
After additional time and working with yet another Windows 10 machine I have successfully gotten this simple test to run.
I can only conclude that there was something on that particular machine preventing proper execution of the test. I wasn't able to figure out what that was, but, the "does it work?" question is answered. It does (which is what one would expect).
conf.js:
// conf.js
exports.config = {
directConnect: false,
framework: 'jasmine',
specs: ['./spec/spec.js'],
seleniumAddress: 'http://localhost:4444/wd/hub',
multiCapabilities: [
{ 'browserName': 'chrome' },
{ 'browserName': 'firefox', 'marionette': true },
{ 'browserName': 'MicrosoftEdge' }
]
};
spec.js:
// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
Results:
[10:07:15] I/launcher - 0 instance(s) of WebDriver still running
[10:07:15] I/launcher - chrome #01 passed
[10:07:15] I/launcher - MicrosoftEdge #21 passed
[10:07:15] I/launcher - firefox #11 passed
So my company is asking me to expand my automated tests for more support of other browsers, namely firefox and safari.
My original suite was designed in Chrome and for the most part, it works pretty flawlessly, and exposes bugs immediately -- a very helpful tool indeed.
I have about 80 testcases that require page navigation and clicks on dynamic urls. This works fine for me up until testcase 7 (and above) which the element I need to click is off the page. How do I know this is the root problem? Because if I put a sleep before the click command and manually scroll the page during firefox execution, the click actually occurs, and I get navigated to the correct page...
Does anyone have a solution for this? I could have swore SeleniumTestCase2 was suppose to remove this issue? I'll post my code below but honestly it works in chrome driver, but not in firefox.
Firefox v43.0 and Selenium jar 4.48.2
protected function selectModule($module = NULL)
{
$this->module = $module;
$this->module = strtolower($this->module);
$this->byID($this->module)->click();
$this->assertEquals($this->url(SOMECONSTANTEXPECTEDURL), $this->byXpath('/html/head/base')->text());
fwrite(STDERR, print_r(__METHOD__."()->$this->module method completed.".PHP_EOL, TRUE));
return $this;
}
Full Stack trace (as requested):
19:44:56.100 INFO - Executing: [find element: By.id: ggk5y3m1])
19:44:56.106 INFO - Done: [find element: By.id: ggk5y3m1]
19:44:56.124 INFO - Executing: [find element: By.id: ggk5y3m1])
19:44:56.131 INFO - Done: [find element: By.id: ggk5y3m1]
19:44:56.142 INFO - Executing: [click: 6 [[FirefoxDriver: firefox on WINDOWS (a9
587de1-e110-454c-b6cb-581612242081)] -> id: ggk5y3m1]])
19:44:56.306 INFO - Done: [click: 6 [[FirefoxDriver: firefox on WINDOWS (a9587de
1-e110-454c-b6cb-581612242081)] -> id: ggk5y3m1]]
19:44:56.308 INFO - Executing: [find element: By.id: ff_frame442])
19:44:57.334 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":
"id","selector":"ff_frame442"}
Command duration or timeout: 23 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/
no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'testing', ip: '10.1.20.115', os.name: 'Windows 7', os.arch:
'x86', os.version: '6.1', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true
, databaseEnabled=true, version=43.0, platform=WINDOWS, nativeEvents=false, acce
ptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserNam
e=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=tru
e}]
Session ID: a9587de1-e110-454c-b6cb-581612242081
*** Element info: {Using=id, value=ff_frame442}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.
java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHa
ndler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:647)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDrive
r.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebD
river.java:403)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDrive
r.java:345)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(Even
tFiringWebDriver.java:102)
at com.sun.proxy.$Proxy1.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(E
ventFiringWebDriver.java:187)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElemen
t.java:48)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElemen
t.java:1)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession
.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element:
{"method":"id","selector":"ff_frame442"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/
no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'testing', ip: '10.1.20.115', os.name: 'Windows 7', os.arch:
'x86', os.version: '6.1', java.version: '1.8.0_66'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:/
//C:/Users/SIMON~1.KYG/AppData/Local/Temp/anonymous2462846570487533916webdriver-
profile/extensions/fxdriver#googlecode.com/components/driver-component.js:10659)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/User
s/SIMON~1.KYG/AppData/Local/Temp/anonymous2462846570487533916webdriver-profile/e
xtensions/fxdriver#googlecode.com/components/driver-component.js:10668)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file://
/C:/Users/SIMON~1.KYG/AppData/Local/Temp/anonymous2462846570487533916webdriver-p
rofile/extensions/fxdriver#googlecode.com/components/command-processor.js:12534)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C
:/Users/SIMON~1.KYG/AppData/Local/Temp/anonymous2462846570487533916webdriver-pro
file/extensions/fxdriver#googlecode.com/components/command-processor.js:12539)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users
/SIMON~1.KYG/AppData/Local/Temp/anonymous2462846570487533916webdriver-profile/ex
tensions/fxdriver#googlecode.com/components/command-processor.js:12481)
19:44:57.338 WARN - Exception: Unable to locate element: {"method":"id","selecto
r":"ff_frame442"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/
no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'testing', ip: '10.1.20.115', os.name: 'Windows 7', os.arch:
'x86', os.version: '6.1', java.version: '1.8.0_66'
Driver info: driver.version: unknown
Thank you #Drets
Code that solved it (a wait for both moving to the damned element and then a wait before clicking it, SMH....)
self::waitforID($this->module);
$this->moveto($this->byID($this->module));
self::waitforID($this->module);
$this->byID($this->module)->click();
//
...
//
protected function waitforID($ID)
{
$this->waitUntil(function () use ($ID)
{
if ($this->byId($ID))
{
return true;
}
sleep(1);
return null;
}, 120000);
}
I am using selenium 2.46 (firefox driver) to develop an application. There are a lot of element.click() in my code. Sometimes that elements are not visible or not clickable make the application throws selenium exception.
When i read the exception, it is so generic, there is no information about what element causes problem.
My question is: is there any way that i can know exactly what element (by name or id) cause the problem.
---Edited: Now i add more detail:
Here is my code
try{
el = webdriver.findElements(By.cssSelector("#accountDropdownSelect-menu li")).get(i);
el.click();
}catch (Exception e){
throw e;
}
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'aaaaa-virtual-machine', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-45-generic', java.version: '1.7.0_80'
Driver info: driver.version: unknown
Command duration or timeout: 1.15 seconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'aaaaa-virtual-machine', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-45-generic', java.version: '1.7.0_80'
Session ID: 40a1ff52-7082-46f2-a05b-e43d9eade760
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{platform=LINUX, javascriptEnabled=true, acceptSslCerts=true, browserName=firefox, rotatable=false, locationContextEnabled=true, webdriver.remote.sessionid=40a1ff52-7082-46f2-a05b-e43d9eade760, version=39.0, databaseEnabled=true, cssSelectorsEnabled=true, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
Just wait for visibility and you don't have to read these exceptions :)
Here's the example:
public static void waitForVisibilityByXPath(final String xpath) {
(new WebDriverWait(driver, timeOut))
.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(By.xpath(xpath)).isDisplayed();
}
});
}
xpath - xpath locator for your element.
timeOut - timeout for the waiting
I actually have the same problem. What I'm doing is:
1.) Simply do a System.out.println("some text that identifies your element.click()") after every element.click() function so you know where it throws the exception.
2.) Surround your element.click() with try+catch and throw your own exception e.g. throw New Exception("some text that identifies your element.click()")
I know it is not very comfortable but I haven't found any other easier solution yet.