selenium web driver - support for storeText - selenium

Selenium IDE I am trying to store text as variable which I can later compare with the database value.
In Selenium IDE
storeText | product >= 999 | prodVal
In webdriver it shows
// ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
Is there a workaround for this?
Thanks

Related

org.openqa.selenium.JavascriptException: javascript error: missing ) after argument list error when updating session storage key value using Selenium

If key value length is 11808 Unable to update session storage key value using selenium automation
Small length key values are setting but long length key values getting JS error
Manually it is working but using selenium automation getting JS error.
setItemInsessionStorage method using:
java.lang.AssertionError: org.openqa.selenium.JavascriptException: javascript error: missing ) after argument list
This error message...
java.lang.AssertionError: org.openqa.selenium.JavascriptException: javascript error: missing ) after argument list
...implies that there is a syntax error within the Javascript line of code.
A bit of more information about your usecase interms of your code block would have helped us to analyze the error in a better way. However in majority of the cases, this error is observed in the following cases:
Incase the " marks are not escaped properly. As an example:
onclick="(canLaunch('" + v.LibraryItemId + " '))"
^ escape character is missing
Ideally, the line should be:
onclick=\"(canLaunch('" + v.LibraryItemId + " '))\"
Incase the function() passed are not closed properly. As an example:
$(document).ready(function(){
}
Ideally, the line should be:
$(document).ready(function(){
});

selenium.common.exceptions.InvalidSelectorException using Selenium in python 3.7

I want to use selenium to automate the process from open a specific website to log in to search for particular articles. Few of the steps I could do it but facing error in 'sign in' step.
from selenium import webdriver
from selenium.webdriver.common.by import By
base = 'https://www.wsj.com'
url = 'https://www.wsj.com/search/term.html?KEYWORDS=cybersecurity&min-date=2018/04/01&max-date=2019/03/31&isAdvanced=true&daysback=90d&andor=AND&sort=date-desc&source=wsjarticle,wsjpro&page=1'
browser = webdriver.Safari(executable_path='/usr/bin/safaridriver')
browser.get(url)
browser.find_element_by_id('editions-select').click()
browser.find_element_by_id('na,us').click()
browser.find_element(By.XPATH, '//button[#type="button"],[contain(.,"Sign In")]').click()
browser.find_element_by_id('username').send_keys('**#&^&#$##$')
browser.find_element_by_id('password').send_keys('###$%%**')
browser.find_element_by_id('basic-login').click()
browser.find_element_by_id('masthead-container').click()
browser.find_element_by_id('searchInput').send_keys('cybersecurity')
browser.find_element_by_name('ADVANCED SEARCH').click()
browser.find_element_by_id('dp1560924131783').send_keys('2018/04/01')
browser.find_element_by_id('dp1560924131784').send_keys('2019/03/31')
browser.find_element_by_id('wsjblogs').click()
browser.find_element_by_id('wsjvideo').click()
browser.find_element_by_id('interactivemedia').click()
browser.find_element_by_id('sitesearch').click()
The code is working till this line:
browser.find_element_by_id('na,us').click()
But after that it is showing error in this line:
browser.find_element(By.XPATH, '//button[#type="button"],[contain(.,"Sign In")]').click()
The error message says​:
selenium.common.exceptions.InvalidSelectorException: Message:
What is wrong is my code?
This error message...
selenium.common.exceptions.InvalidSelectorException
...implies that the XPath expression was not a valid one.
However, it seems you were close. You need to replace:
'//button[#type="button"],[contain(.,"Sign In")]'
and join the two condition with and operator as follows:
"//button[#type='button' and contains(.,'Sign In')]"

automated testing ngx-datatable using robotframework with selenium

Has anyone used robotframework to test ngx-datatable? Since it isn't set up like a regular table, the selenium libraries Get Table Cell function doesn't work. Does anyone have an example of a work-around?
I've come up with a script that works for the time being.
*** Variables ***
${Table} = css=div[class^="datatable-row-center"]
*** Keywords ***
Get Value From Grid
#{RowNumber} 0 is the header
#{ColNumber} 0 is first column
[Arguments] ${RowNumber} ${ColNumber}
Sleep 3s
#{Table_Rows}= Get Webelements ${History_Table}
${Text}= Get Text #{Table_Rows}[${RowNumber}]
#{words} = Split String ${Text} \n
Log to Console #{words}[${ColNumber}]
[Return] #{words}[${ColNumber}]
This works as long as the class on the table rows remains 'datatable-row-center'

Save a value for later use in Selenium IDE

I am programming a test case in Selenium IDE and I find the following problem:
I have the following ID
Id = lblInfo The operation (35) has been successfully generated.
The number (35) is logically varying depending on the number of operation that is created. I need to somehow extract the number between () for later use.
I have tried using the storeText command
But as you see in the example it only takes the id = lblInfo and not the rest of the message (The operation has been successfully generated (35))
storeText
id = lblInfo
myVar
How can I do in this case ??
Man you can get the number using regular expression like
COMMAND TARGET VALUE
StoreEval StoredVars['Your_variable'].match(/\d+/) new_variable
You will get 36 in new_variable (you can name it anything)

TypeError: Failed to execute 'createNSResolver' on 'Document': parameter 1 is not of type 'Node'

I'm using Cucumber with Watir Web-driver and Chrome browser.
When I execute my tests, sometimes there is an error like this:
"Selenium::WebDriver::Error::InvalidSelectorError: invalid selector: Unable to locate an element with the xpath expression //a[contains(., 'Joao Moreira')] because of the following error:
TypeError: Failed to execute 'createNSResolver' on 'Document': parameter 1 is not of type 'Node'.
(Session info: chrome=43.0.2357.81)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64)"
I tried to get an answer trough Google but with no success.
Pretty sure this is this issue here: https://code.google.com/p/selenium/issues/detail?id=8600
And it is fixed as of Selenium 2.46.0. I haven't seen the error since moving.
Add a line to handle the exception thrown. Seems like the error halts the test. This has nothing to do with the locator, or iframe.Try to wrap your method in rescue clause:
begin
{your method}
rescue
Selenium::WebDriver::Error::InvalidSelectorError
end