Selecting by a numeric id in grails geb - grails

Using the chrome driver for selenium, I'm trying to select an element from my page by its id, which is numerical (ie 1000).
This fails, giving:
org.openqa.selenium.InvalidElementStateException: findElements execution failed;
SYNTAX_ERR: DOM Exception 12 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13 milliseconds
Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-33-generic', java.version: '1.7.0_09'
Driver info: driver.version: RemoteWebDriver
However, if I change the id to be some string that is composed not exclusively by numbers (ie m1000), the selection works.
Any idea why this is happening?

Seems that it's because ID tokens must begin with a letter ([A-Za-z]), see http://w3.org/TR/html401/types.html#type-name

Related

Not able to interact with application using any of the locator - throwing me 'Locator Strategy 'name' is not supported for this session'

Testing an Android app and not able interact with app
Tried with ID, xpath and other locator but still display same error message.
#AndroidFindBy(xpath = "//android.widget.Button[#text='English']")
public WebElement language;
#AndroidFindBy(xpath="//android.widget.Button[#text='GET STARTED']")
public WebElement start;
The error I am getting is:
FAILED: login org.openqa.selenium.InvalidSelectorException: Locator Strategy 'name' is not supported for this session For documentation on this error, please visit: seleniumhq.org/exceptions/invalid_selector_exception.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'nsubramani-mbp-1', ip: 'fe80:0:0:0:10b4:b83f:ee48:38b2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_202' Driver info: io.appium.java_client.android.AndroidDriver

Browser is not opening when running Jenkins as a service

I am running my selenium tests in IE in a Windows VM with the help of Jenkins. When running java -jar jenkins.war, my suite is working fine..
But when Jenkins is running as a service, browser is not opening and always it is failing.
I have opened the service properties and given Allow service to interact with desktop.
The alternate way I am running java -jar jenkins.war as a start up.. But this is starting jenkins when I login VM but if some circumstances due to windows patch update if machine gets restarted this is not working until I login the VM which is not i want.
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:\Windows\TEMP\scoped_dir6052_18573}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=70.0.3538.102, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: e6ef32b1e294ce9644a5078d9b8bf8c4
Failed ***********
Started InternetExplorerDriver server (32-bit)
2.51.0.0
Listening on port 45007
Only local connections are allowed
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:45007/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: dbbe2316-a3b3-4e39-82e3-04dae698ec73
Nov 16, 2018 6:17:43 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: txtUserName)
org.openqa.selenium.UnhandledAlertException: Modal dialog present:
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'xxx-xx-xx', ip: 'xx.xx.xxx.xxx', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Error log states that your test failed because of:
org.openqa.selenium.UnhandledAlertException: Modal dialog present
It happens when some alert appeared and was not properly handled by your test. To fix it you need to add a logic to handle alert before you call a method to look for an element findElement(By.id("txtUserName")). The code might look like this:
try {
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
} catch (NoAlertPresentException ignored) {
//if alert is not present for some reason we don't want to fail and can continue a test
}
or you can wrap to a findElement call with a try catch, then close the alert, and try your logic again:
WebElement el;
try {
el = findElement(By.id("txtUserName"));
} catch (UnhandledAlertException f) {
try {
Alert alert = driver.switchTo().alert();
System.out.println("Alert appeared. Text= " + alert.getText());
alert.accept();
el = findElement(By.id("txtUserName"));
} catch (NoAlertPresentException ignored) {
//if alert is not present for some reason we don't want to fail and can continue a test
}
}

Problems starting iOS driver

I am having difficulty with executing a test with my driver.
1) I start my server with the following (grid does not start as I am getting kicked out… for another thread)
java -jar ios-server-standalone-0.6.6-SNAPSHOT.jar -port 1111
2) I launch a test from the respective directory
3) The logs dump the following:
The server cannot run Capabilities [{platform=MAC, cssSelectorsEnabled=false, CFBundleIdentifier=com.apple.mobilesafari, javascriptEnabled=true, nativeEvents=false, locale=en_GB, CFBundleName=Safari, variation=Retina4, device=iphone, rotatable=false, takesScreenshot=false, sdkVersion=7.1, version=}] at the moment.org.uiautomation.ios.application.APPIOSApplication cannot be cast to org.uiautomation.ios.application.IPAApplication
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '(hidden for privacy)', ip: '(hidden for privacy)', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_67'
Driver info: driver.version: unknown
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '(hidden for privacy)', ip: '(hidden for privacy)', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_67'
Driver info: driver.version: unknown (org.openqa.selenium.SessionNotCreatedException) (Selenium::WebDriver::Error::WebDriverError)
[remote server] org.uiautomation.ios.command.uiautomation.NewSessionNHandler(NewSessionNHandler.java):100:in `safeStart'
What is the root cause?
Having had the exact same issue, you could try using
capabilities.setCapability("simulator", true);
This got me past this issue at least (and into another one).

Timeout error when doing a search in a web page using protractor

I've done a lot of searching on the web for this issue and haven't found a solution. I am using Protractor to drive a web test and perform a search query in the UI. The results take a while to come back (approximately 8 minutes). I added the 'allScriptsTimeout' argument to my config file for 10 minutes, but it doesn't seem to help. The timeout error appears every time at the 5 minute mark, regardless. Any ideas on what else I can try in order to bypass this seemingly hard-set timeout? The error I am getting is this (partial):
ScriptTimeoutError: timeout: Timed out receiving message from renderer: 299.988
(Session info: chrome=36.0.1985.143)
(Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 SP1 x86) (WARNI
NG: The server did not provide any stacktrace information)
Command duration or timeout: 300.13 seconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
Session ID: dc370ac53e9afba8a2f69e82e0c42d0b
Driver info: org.openqa.selenium.chrome.ChromeDriver
....
Try to also specify setScriptTimeout and pageLoadTimeout to 20 minutes like this:
browser.manage().timeouts().setScriptTimeout(60*20*1000);
// Warning: Below option is not supported in Safari webdriver
browser.manage().timeouts().pageLoadTimeout(60*20*1000);

Error with iOS driver set up

As per the instruction with http://ios-driver.github.io/ios-driver/?page=setup , i am trying to set up ios driver my application first testing using this automation.
I have installed java 7 and downloaded the app in given link. Installed OSX 10.9. While executing the command $ java -jar ios-server-0.6.6-SNAPSHOT-standalone.jar -aut path/to/aut.app -port 4444 i am getting below error
45:08:315 INFO ApplicationStore.<init> App archive folder:/Users/labuser/Downloads/applications
false
45:08:838 SEVERE IOSServer.main cannot start ios-driver server: org.openqa.selenium.WebDriverException: path/to/aut.app isn't an IOS app.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9', java.version: '1.7.0_55'
Driver info: driver.version: unknown
Any one suggest me to resolve this error and am new to use commands in terminal
It looks like path/to/aut.app is a placeholder and you need to replace it with the path to your application.

Resources