The number '3' gets skipped in ruby-cucumber autoamtion [duplicate] - ruby

For some reason, I am unable to write character '3' into the input element on the page.
This code:
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
chrome_options.add_argument('--no-proxy-server')
chromeDriverPath = self.getChromeDriverPath()
os.environ["webdriver.chrome.driver"] = chromeDriverPath
self.driver = webdriver.Chrome(chromeDriverPath, chrome_options=chrome_options)
self.driver.get(self.loginUrl)
login = self.driver.find_element_by_id('login_credit')
login.send_keys("12345")
results in "1245" being written in the login input...
Can someone help please?
I use python 2.7, the latest chrome and the latest chromedriver
EDIT:
login.send_keys("3")
login.send_keys("\3")
don't work either.
login.send_keys("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!##$%^&*()")
- only the "3" was missing in the string...
what worked was
login.send_keys(Keys.NUMPAD3)
as Andersson suggested below, but this is not a solution.
I tried it in the google search box and I experienced the same behaviour.

Updating to latest chrome driver resolved this issue.

Instead of using send_keys("12345") you can use any of the alternatives mentioned below :
Use Keys.NUMPAD3 :
login.send_keys(Keys.NUMPAD3)
Use JavascriptExecutor with getElementById :
self.driver.execute_script("document.getElementById('login_credit').value='12345'")
Use JavascriptExecutor with getElementsById :
self.driver.execute_script("document.getElementsById('login_credit')[0].value='12345'")

Strange issue, Try to pass string variable in send_keys and try may be it works for you
my_str = "12345"
login = self.driver.find_element_by_id('login_credit')
login.send_keys(my_str)

Related

Is there a way to make RichEmbed methods work in Heroku?

When attempting to use this code I got the error below:
const embed = new RichEmbed();
var num = Math.floor(Math.random() * 10);
let name = part + num + ".gif";
embed.attachFiles([name]);
embed.setImage('attachment://' + name);
mess.channel.send(embed);
TypeError: embed.attachFiles is not a function
I if I delete away embed.attachFiles([name]) I get an error saying that embed.setImage isn't a function either.
Is there anything I can do to make Heroku register these as functions? It is worth noting that this worked outside of Heroku, when I ran it using the command line on my own computer.
Heroku by itself does not modify the behavior of discord.js. Here's a list of things you can try:
Verify that your package.json file is updated with the version of discord.js you want and run npm i to make sure the version on your pc is the same*.
Make sure that RichEmbed is Discord.RichEmbed: try to write it explicitly to see if that helps.
Try to console.log(embed) and see what gets logged in the console: that might give you a clue of what the problem is...
* The RichEmbed.attachFile() method was added in the 11.0.0 version: any previous version of discord.js won't allow you to use it.

Running gulp using Symfony Process results in command not found

I am trying to run gulp using envoy from a controller on a Laravel installation using Symfony Process to no luck. I keep getting an error back reading "The command "envoy" failed. Exit Code: 127(Command not found)". I have attached the code I am using below:
$process = new Process('envoy', base_path() . '/vendor/laravel/envoy');
$process->setTimeout(60);
$process->setIdleTimeout(60);
$process->setWorkingDirectory(base_path());
$process->run();
$process->start();
$process->wait();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
My question is, how come the command is being read as not found even though I am targeting it directly?
Thanks in advance for the help!
I believe you need to change this line like so:
$process = new Process('envoy vendor/laravel/envoy');
can you try it? Not certain it work, but I think it's something like that. Since you are using base_path(), I think it's pointing to a different directory than you expect.

Ohai thinks my plugin is version 6. Why?

I'm trying to write a plugin for ohai. It seems like a pretty straightforward task:
Ohai.plugin(:Uname) do
provides 'uname'
depends 'kernel'
collect_data do
uname Mash.new
uname[:message] = `uname -a`
end
end
To me this looks like the online examples provided by Opscode, O'Reilly and others. But here's what happens when I try to test it:
% irb -rohai
irb(main):001:0> Ohai::Config[:plugin_path] << "."
=> ["/home/ll0359/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/ohai-8.3.0/lib/ohai/plugins", "."]
irb(main):002:0> o = Ohai::System.new
=> #<Ohai::System:0x007fed82e43078 #plugin_path="", #data={}, #provides_map=#<Ohai::ProvidesMap:0x007fed82e42fd8 #map={}>, #v6_dependency_solver={}, #d82e42f38 #controller=#<Ohai::System:0x007fed82e43078 ...>, #v6_plugin_classes=[], #v7_plugin_classes=[]>, #runner=#<Ohai::Runner:0x007fed82e42ec0 #prp:0x007fed82e42fd8 #map={}>, #safe_run=true>>
irb(main):003:0> o.all_plugins
And here's where the fun begins. I get this output, over and over and over:
[2015-05-20T03:13:09+00:00] WARN: Plugin Definition Error: <./ohai_uname.rb>: collect_data already defined on platform default
[2015-05-20T03:13:09+00:00] WARN: [DEPRECATION] Plugin at ./test_ohai.rb is a version 6 plugin. Version 6 plugins will not be supported in future releases....
your plugin to version 7 plugin syntax. For more information visit here: docs.chef.io/ohai_custom.html
(the text on my second line was clipped by my screen but you get the idea)
I've tried running this code with and without the 'depends' line. Same result.
I've tried running this code with and without the Mash line, substituing 'uname uname -a' for the assignment line. Same result.
I've tried running with and without passing ":linux" as a parameter to collect_data. The only difference is I get a warning about collect_data(:linux) already being defined instead of :default.
I've tried renaming the plugin to a random 8 character identifier just in case it was tripping over being called :Uname. Same result.
I've tried passing "uname" (capital and lower) as a parameter to o.all_plugins. Same result.
So my questions are:
Why does ohai (8.3, running under Ruby 2.2.1) think this is a version 6 plugin? I can't see anything in it that would make it look like it's not version 7.
How can I get this working?
Thanks
Note to self: Next time you do this, don't try to test from the directory your plugin is in and add "." to your plugin_path. Moving to a different directory and adding the absolute path to the plugin solved the problem.
I plan to leave this up in case someone else has this happen to them.

Running casperjs tests with slimerjs

I wrote a few tests with casperjs. They run just fine with phantomjs. However, when I tried to use slimerjs with the following command:
casperjs --verbose --engine=slimerjs test create-project-suite.js
A small window appers with the SlimerJs logo and version number but the console seems to hang with the following line:
Test file: create-project-suite.js
Is there anything else I need to do? Here are the version numbers:
Mozilla Firefox 28.0
CasperJS version 1.1.0-beta3
Innophi SlimerJS 0.9.1
3.8.0-37-generic #53~precise1-Ubuntu
Update:
I removed code until I got slimerjs to open the browser and execute tests. It seems that it hangs whenever I require a js file (I'm following the page objects pattern):
var Login = require('./objects/login');
I think require.paths could be helpful. Any ideas on how to get around this?
Using full paths makes slimerjs happy:
var path = fs.absolute(fs.workingDirectory + '/objects/login');
var Login = require(path);
It is plain simpler to move all modules to the same directory where the script is.
I tried your command and it works for me, maybe in your file you use an instruction specific to phantom :
http://docs.slimerjs.org/0.8/differences-with-phantomjs.html
But it should open the window(at least the start() ).
Anyway the command is fine.

what is the difference between stensi & WanWizard datamaper versions?

I've tried stensi but I see it has some mistakes and unexpected output as mentioned in the user guide.
For example, when trying to delete a record it gives this error:
$p=new Per();
$p->where('id',1)->get();
$p->delete();
with an error message of:
undefined index id
when
echo $p->UserName;
outputs:
mhmd
and WanWizard has also this error:
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: array_key_exists() expects parameter 2 to be array, boolean given</p>
<p>Filename: libraries/datamapper.php</p>
<p>Line Number: 399</p>
How can I overcome these errors or what can I do to make it work properly?
I've changed the two lines of code at ../libraries/datamapper.php line 399 (WanWizard version):
$d = array($this->config->item('datamapper'));
DataMapper::$config = $d;
and the error message disappeared.
If anyone has tried DataMapper and has a better suggestion, please let us know.
just found out this error can occur if you autoload the datamapper config file
Stensi's original version hasn't been maintained since 2007, and only supports CI 1.4. Not really an option anymore these days. It was forked by Overzealous in 2008, and I took over maintenance of that fork in 2010.
I fixed this (in the CI spark version) by moving the config file from the sparks directory to the /application/config directory.
There's something strange happening in CI v2.1.4 where
$this->config->load('datamapper', TRUE, TRUE);
on line 391 of application/libraries/datamapper.php in Datamapper-ORM v1.8.2.1 isn't "namespacing" the config correctly. If you do
print_r ($this->config); die;
just after line 391, you'll see all of the config values are in the general CodeIgniter "namespace" inside the loaded config array. The least intrusive way to get around this is to manually namespace your application/config/datamapper.php file yourself, by changing all the references from
$config['prefix'] = '';
$config['join_prefix'] = '';
...
to
$config['datamapper']['prefix'] = '';
$config['datamapper']['join_prefix'] = '';
...
That's how I got around it. Though #Mhmdgomma's fix does work, I prefer not to hack the core of the system when there is a simpler solution available. Someone should probably get the maintainers to fix this, but I'm not sure where the issue lies. It looks more like it's a CI issue, rather than DM.

Resources