Getting the error while trying to run the code for selenium/selenide script to execute script on browserstack - selenium

Error description -
java.lang.IllegalArgumentException: The class org.openqa.selenium.remote.RemoteWebDriver of the given context doesn't implement io.appium.java_client.FindsByIosNSPredicate nor io.appium.java_client.FindsByFluentSelector. Sorry. It is impossible to find something
Please help me if someone have any idea about it.
will add more details, if someone wants.

Looks like the element locator strategy FindsByIosNSPredicate and FindsByFluentSelector is not being captured by the default appium version. Can you try explicitly mentioning the appium version capability and pass the same as passed while executing your tests locally on a real device. You may refer to this: https://www.browserstack.com/automate/capabilities or https://www.browserstack.com/app-automate/capabilities ( for App )

Related

Browser not quitting when called from another scenario using Karate

I have a scenario which is a series of rest api calls but in the middle is a section that executes a few steps within a chrome browser. The browser steps are common to another scenario so I tried to extract the browser steps into a separate feature that could then be called from multiple scenarios.
When the main scenario executes it executes the browser feature but fails to auto-close the browser after execution. I read in the documentation "Karate will close the browser automatically after a Scenario unless the driver instance was created before entering the Scenario" . The configure driver code is in the callable scenario.
I also tried caling quit() but this resulted in the error: "The forked VM terminated without properly saying goodbye. VM crash or System.exit called?"
Does anyone know how I can ensure the browser closes in this circumstance?
UPDATE: As suggested by #PeterThomas I started to craft a full example to replicate this when I discovered that to replicate is actually quite simple.
If the UI feature is called like this then the browser is closed after execution:
* call read('classpath:/ui/callable/GoogleSearch.feature')
If called like this then the browser remains open:
* def result = call read('classpath:/ui/callable/GoogleSearch.feature')
My UI scenario scrapes a value from a web page which I then stored within a '* def ticket' within the called feature. I was hoping to access it via result.ticket. As I am unable to do this I am successfully using the following:
* def extractedTicket = { value: '' }
* call read('classpath:/ui/callable/GoogleSearch.feature')
* def ticket = extractedTicket.value
And within the called feature:
* set extractedTicket.value = karate.extract(val, '.ticket=(.*?)&', 1)
First, I think you should provide a way to replicate this, so that we can investigate and fix this for everyone. Please follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue
That said, maybe for just getting Chrome to do a few steps you should just use the Java API - and you can call it from wherever you want, even within a feature file using Java interop: https://github.com/karatelabs/karate#java-api
Also see if this answer gives you any pointers: https://stackoverflow.com/a/60387907/143475

Selenium WebDriverException missing ) after argument list

js.executeScript("document.querySelector('input[name='password']');");
This line is throwing the following Exception in thread:
"main" org.openqa.selenium.WebDriverException: missing ) after argument list
Try the following code.
js.executeScript("document.querySelector('input[name=\'password\']')");
Try
js.executeScript("document.querySelector('input[name='password']')");
Let me know if this Answers your Question.
You can try one of the following
js.executeScript("document.querySelector(\'input[name=\'password\']\');");
js.executeScript("document.querySelector(\"input[name='password']\");");
Although in your comments you added this line
js.executeScript("document.querySelector('input[name=\'pas‌​‌​sword\']').value='ga‌​‌​mb'");
Which wouldn't work because if you look at .value you'll need to escape your .value setting as well more than likely.
Given that I don't have access to your site or your code, I would suggest that you test to make sure your javascript is valid for your page. One way to do so would be to take the javascript itself (everything insdie the .executeScript) and run it through your browsers dev tools console or script execution window.
If the value sets using the browsers dev tools, great...issue is with selenium. If the value does not set using browser dev tools...you'll need to refactor your javascript as the problem is likely not with selenium, rather your JS selector more than likely.
Although, the following, from your comment, works...you may not need to execute it via javascript.
driver.findElement(By.cssSelector("input[name='password']"‌​‌​)).sendKeys("gamb"‌​);

Selenium RC - t.replace is not a function

[edit for godman] I am working on a web based application, written in PHP. I am using Selenium RC to run tests on the webpages produced by this application, through a browser.
I just upgraded to Firefox 14, so I had to upgrade to Selenium RC 2.25.0.
Now I'm seeing this error when running a test with htmlSuite:
Command execution failure. Please search the user group at
https://groups.google.com/forum/#!forum/selenium-users for error
details from the log window. The error message is: t.replace is not a
function
The command executed is:
clickAndWait //a[text()='! selenium test customer']
As you can see, it's not doing anything too tricky - just clicking a link. The test runs fine in the IDE, it's just when run via RC that it's a problem.
Searching in the groups revealed only really old threads dating back to version 1 of selenium.
Any ideas anyone?
[edit] I've been running the test that has these problems several times a day for the last week - and it doesn't seem to fail like this every time. This looks like it's a random problem. Has anyone seen this happen before?
[edit after the bounty got me no answers] Another example of it failing is with:
clickAndWait css=a.edit_company
This same call works fine earlier in the same test, on the same page.
[edit] Now I'm seeing the same error with a completely separate command:
type id=Address1 Address1
Does anyone have any suggestions about this? Any way I can even debug what's going on (I don't see this in the IDE at all)
I am not terribly familiar with clickAndWait. I personally prefer clicking and then doing my own custom waiting.
Try just clicking and add a Thread.Sleep(5000), or something similar, and see if the error is a result of the click or the wait part.
If it is the wait part, then I have a different suggestion than if it is the click part.
I've seen similar issues across various platforms. It has always been somewhat random for me, so I don't use clickandWait. Generally is is much more reliable to do a plain click, and then wait for specific condition. You could do a waitforpageload, but that has also been unreliable for me so I prefer things like waitfortextpresent and waitforelementpresent.
Usually, this kind of error would occur if you are dealing with something that is not a string. Could you just make sure that you are dealing with strings only?
2 possibilities where it is arising from:-
When text() is executed -> it might be dealing with a non-string
a[expression] -> the expression(text() = '! selenium test customer') when evaluated to False/True might be the problem because if a is a Map/array, the corresponding key should be a string and not a bool, probably.
text()='! selenium test customer' -->> is it an assignment operation? if yes, make sure that text() returns a lvalue or a mutable object (based on the language you are using selenium rc with)

Getting error in selenium test cases

I'm running somebody written selenium test cases in my system.It showing the few errors like
> [error] Actual value 'null' did not match '[object Object]'
> [error] Threw an exception: this.browserbot.getUserWindow().map is undefined
> [error] Threw an exception: this.browserbot.getUserWindow().map is undefined
Is it the problem with selenium ide version which I'm using or other? I'm using Selenium 1.6.0
This issue is coming because you are trying to get hold of a window , which is not matching to the value you are passing.
So for this you need to investigate more on your locators. Also you can start using a new tool which can find automatically the locators for you , which is Selenium Builder. Hope following links will help you.
http://khyatisehgal.wordpress.com/2014/05/26/selenium-builder-exporting-and-execution/
http://khyatisehgal.wordpress.com/2014/05/25/selenium-builder/
Those errors you're getting are not because of Selenium version, but because the logic of your application changed and the tests expect different results from various actions.
The only thing you can do is to go through your tests, discover what were they trying to assert / achieve / test (you do have your testcases documented, right?) and if their current behaviour is wrong, fix them.
The other possibility is that your tests are ok, just the application began to behave differently (against the spec) and needs to be fixed. But from the context, I'd say that your unmaintained tests broke.

Create screenshot after failed selenium command

The PHPUnit Selenium base class has an option to make a screenshot on failure, which is a huge help in finding out why the test failed. The selenium server, however, returns an error instead of a failure on any error condition other than explicit assert* calls (such us trying to do something with a non-existent element). If I try to make a screenshot after the server reports the error, I get another error saying that the server already discarded the session. Is there any way to change that behavior?
Update: this is because PHPUnit breaks the connection when it receives an error. I was able to change it by some (rather ugly) manipulation of the PHPUnit code.
Make those interactions as test cases.
For example in perl,
If it is written as below and fails due to a non-existent element. the script will error out
$sel->type("email-id","trial\#trial.com");
While if the above step is made as a test case by writing it as follows
$sel->type_ok("email-id","trial\#trial.com");
If there is a non-existent element, the test case will only fail, and the script will continue.
So using TAP (test any protocol) by using the module use Test::More; , if _ok is added after a function, the function return will be used to determine the fate of the test case.
ie. - A return of 'O' means the test Failed
and A return of '1' means the test Passed
It is not the Selenium server but the SeleniumTestCase class for PHPUnit 3.4 which automatically sends a stop command when it detects an error (Driver.php line 921). PHPUnit 3.6 seems handle errors better.
I think you can overwrite method 'travelbox' and make something like this:
public function onNotSuccessfulTest(Exception $e){
file_put_content('/xxx/xxx.jpg', $this->currentScreenshot());
}