I need some help!
Please find below my selenium IDE code which when converted to webdriver code gives me // ERROR: Caught exception [ERROR: Unsupported command [isTextPresent]]
<tr>
<td>assertTextNotPresent</td>
<td>//*[#id='collapseComment']/div/div/div[2]/label</td>
<td>Max. 3072 characters</td>
</tr>
Basically I want my test to fail if it find the text string 'Max. 3072 characters' on the page during runtime
I would be grateful if someone can please help me by providing java equivalent of this which i can use.
Cheers
Shan
The first thing I see is that the IDE command of assertTextNotPresent does not accept a target and value. It only needs a target that contains the pattern of the text being searched on. Currently your test asserts that the text of "//*[#id='collapseComment']/div/div/div[2]/label" is not anywhere on the page.
If you use the IDE command of assertNotText it will work correctly. assertNotText requires a locator in the target and a value to compare. When you use IDE to export to Java it will translate assertNotText correctly.
With that in mind, in Java with JUnit 4 the answer is :
WebDriver driver = new FirefoxDriver();
...
WebElement element = driver.FindElement(By.XPath("//*[#id='collapseComment']/div/div/div[2]/label"));
assertThat("Max. 3072 characters", is(not(element.getText())));
or
assert(false, element.getText().contains("Max. 3072 characters"));
You didn't say what assertion/unit testing framework you are using, but this is in C# and NUnit:
IWebDriver firefoxDriver = new FirefoxDriver();
IWebElement element = firefoxDriver.FindElement(By.XPath("//*[#id='collapseComment']/div/div/div[2]/label"));
Assert.IsFalse(element.Text.Contains("Max. 3072 characters"));
Related
In the project I'm working on, we have a lot of file input fields with an opacity of 0.
if I have an input field wih an id of file_upload and opacity:0,
then #driver.find_element(id: 'file-upload').send_keys full_file_path will give me a Selenium::WebDriver::Error::ElementNotVisibleError
How can I successfully attach a file to this input?
Im am using selenium-webdriver for Ruby
Note:
I know that this is possible to do with Capybara but using Capybara is not currently an option in my project.
One option is to it with execute_script instead of find_element.send_keys:
full_file_path = "./path/'
script = <<-JS
document.getElementById("#file-upload").val("#{full_file_path}")
JS
#driver.execute_script script
The Java code, which is working fine.
WebDriver driver = new ChromeDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.querySelector(\"input[id*='upload']\").style.opacity='1'");
driver.findElement(By.cssSelector("input[id*='upload']")).sendkeys(filepath);
I am getting the following error when I try to start my Application...
[java.lang.IllegalStateException: java.lang.NullPointerException^M
at com.tivoli.pd.jutil.kb$1.run(kb$1.java:41)^M
at java.security.AccessController.doPrivileged(AccessController.java:229
)^M
at com.tivoli.pd.jutil.kb.c(kb.java:141)^M
at com.tivoli.pd.jutil.kb.(kb.java:56)^M
at com.tivoli.pd.jutil.PDContext.(PDContext.java:76)^M
at com.tivoli.pd.jazn.PDAuthorizationContext.(PDAuthorizationConte
xt.java:66)^M
I double checked the config file was accessible and I could read it. The code I am using looks as follows...
aC = new PDAuthorizationContext(cFile);
Is there a way to get more information on what is causing the NPE?
More information!!!
After debuging a bit, it appears the issue comes from this code (they use progaurd so it is a little hard to be 100% confident)...
Certificate[] arrayOfCertificate1 = ((KeyStore)???).getCertificateChain("DefaultID");
//Throws Null pointer (presumably because array is null)
Certificate localCertificate1 = arrayOfCertificate1[0];
EVEN MORE INFO
This appears to be some kind of dependency conflict (guess), because if I just create a sample App using PDAuthorizationContext it works fine.
Problem was related to the PD.jar version that I was using. Although I thought I was using one version I was using another. This was because on version was registered in my WebSphere library (under build path in eclipse). Once the proper library was introduced everything worked.
I'm trying to learn how to use attributed strings. This statement caused a "EXC_BAD_ACCESS":
NSDictionary *attDict = #{ NSForegroundColorAttributeName : [UIColor redColor] };
The way I read the documentation NSForegroundColorAttributeName is an NSString, so I then tried this but got the same crash:
NSLog(#"NSForegroundColorAttributeName: %#", NSForegroundColorAttributeName );
and also this and got the same crash:
NSString *fcan = NSForegroundColorAttributeName;
So it looks like any mention of NSForegroundColorAttributeName causes a crash. I did try other xxxAttributeNames and they do the same thing. I am importing UIKit/UIkit.h. There are no compiler warnings and no run time messages. What am I missing? Is there something else I need to import or assign? Do I have the whole concept wrong? I don't think there are any Apple code samples that cover this.
Using the newer NS* constants compiles because the extern for them is present in a header (if you build with "Latest iOS" SDK, but if you execute this code on a device that has not iOS 6 but lower then you get the crash you describe.
I'm trying to test for the presence of a string somewhere in a long webpage. Using PHPUnit's assertRegExp if the string is not found it prints out the entire page and then finishes with matches PCRE pattern "/xxxxxx/". According to the documentation I should be able to specify a message a third that will be printed out if the test fails. That message is printed, followed by the full page source. What I'd like to do is just print the message. Using Selenium in my previous apps I used assertTextPresent and it would just print out confirmation that the text was/was not found, without filling my screen.
I have tried wrapping the assertRegExp in a try-catch but it didn't change anything.
You could try assertContains() instead of assertRegexp().
PHPUnit is responsible for printing out the failed text, and this differs from one assert method to another. It just might work.
If it does not, open an issue at PHPUnit's issue tracker about PHPUnit printing too much out.
I am using the getBodyText() method to get all page content and than I use assertTextPresent() to check the presence of pattern.
$this->assertTextPresent($this->getBodyText(), 'text to find');
The solution has been positivly tested with latest phpunit 4.7.
I use assertTrue(stripos($haystack, $needle) !== false, 'Failed assertion message');
I am trying to find out the error for two days but still haven't got this unknown reason figure out.
I have configured and compiled Botan library. Everything goes ok but when try to write this sample code to be run..
S2K* s2k = get_s2k("PBKDF2(SHA-256)");
s2k->set_iterations(4049);
SecureVector<byte> key_and_IV = s2k->derive_key(48, passphrase).bits_of();
SymmetricKey key(key_and_IV, 32);
it says error: 'class Botan::PBKDF' has no member named 'set_iterations'
How can I solve this problem ?
The Botan docs for v1.11.1 report that the function get_s2k() has been deprecated, recommending that you use get_pbkdf() instead.
According to the docs, get_sdk(algospec) just returns the result of a call to get_pbkdf(algo_spec) which will give you a pointer to an instance of the class Botan::PBKDF.
First things first then, your code needs to be something more like:
PBKDF *s2k = getpbkdf("PBKDF2(SHA-256)");
Unfortunately without knowing what you want to do with s2k I can't help any further, as the docs have no reference to a public member function of PBKDF called set_iterations(). You're getting the error you mention because Botan::PBKDF really does have no member named set_iterations. You need to read the docs, work out what the purpose of set_iterations() was in your now deprecated example and hence how to achieve that purpose in the newer version of the library.
Possibly you missed your library header... as your error message says: 'has no member named...'