Protractor css locator for md-select - protractor

I'm new to protractor and need to know how can i get the text i.e. Connections in the below code block. I need to click this "Connections". Anyhelp would be really appreciated. Thanks in advance
<md-option ng-repeat="worksite in vmSplashController.worksites track by $index" id="option_worksite_TRANSFER" ng-value="worksite" tabindex="0" class="ng-scope" role="option" aria-selected="false" value="[object Object]">
<div class="md-text ng-binding">
Connections
</div>
</md-option>
Full code
<md-dialog ng-cloak aria-span="" id="splashDialog" class="asui-popup-container splashContainer">
<form name="splash">
<md-dialog-content class="agentDetails" flex>
</md-dialog-content>
<md-dialog-content class="agentOptions" flex layout="row">
<md-input-container class="md-input-has-placeholder" id="nav_worksite" ng-if="vmSplashController.worksites.length >= 1" flex="50" layout="column">
<label class="select-lable">Worksite</label>
<md-select md-no-ink name="nav_worksite" required ng-model="vmSplashController.worksites.selected" ng-model-options="{trackBy: '$value.locationCode'}" aria-label="Select Worksite" md-container-class="md-select-custom nav-worksite-selectbox" ng-change="vmSplashController.onWorksiteChange(vmSplashController.worksites.selected)">
<md-option ng-repeat="worksite in vmSplashController.worksites track by $index" id="option_worksite_{{worksite.locationCode}}" ng-value="worksite">
{{**Here that Div is being created i.e. Connections along with other two options**}}
</md-option>
</md-select>
</md-input-container>
</md-dialog-content>
<md-dialog-actions layout="row">
<md-button md-no-ink class="md-primary nobg-btn" ng-click="vmSplashController.onConfirm()" ng-disabled="splash.$invalid">
CONFIRM
</md-button>
</md-dialog-actions>
</form>
</md-dialog>
I treid this
element(by.cssContainingText('.option_worksite_TRANSFER > div.md-text', 'Connections')).click();
but getting the below error.
Message:
Failed: No element found using locator: by.cssContainingText(".option_worksite_TRANSFER > div.md-text", "Connections")

First - I'm a bit confused. In example you are trying to select class option_worksite_TRANSFER, but in error message it has an id.
If you are trying to select value from dropdown, try this solution:
https://stackoverflow.com/a/39047319/6331748

Try this using xpath:
element(by.xpath("//div[text()='Connections']")).click();

Try using the below code:
element(by.cssContainingText('[id^="option_worksite"] > div.md-text', 'Connections')).click();
Adding waits:
var EC = protractor.ExpectedConditions;
var ele = element(by.cssContainingText('[id^="option_worksite"] > div.md-text', 'Connections'));
browser.wait(EC.visibilityOf(ele), 5000).then(function(){
ele.click();
});

Related

How do I pass Variants as props to React Components in ReasonML?

I have tried the following approach to be able to send variants as props.
type ipAddr =
| IPV4
| IPV8;
[#react.component]
let make = () => {
let appData = Data.tileData;
<div className="App">
<header className="flex outline justify-between" />
<Content selected={ipAddr.IPV4} appData />
</div>;
};
But it throws the error,
ninja: error: rebuilding 'build.ninja': subcommand failed
I have tried sending variants directly to Component as well.
<div className="App">
<header className="flex outline justify-between" />
<Content selected=IPV4 appData />
</div>;
But it ended up returning another error
Start compiling ninja: error: dependency cycle: src/App-ReactHooksTemplate.cmj -> src/Content-ReactHooksTemplate.cmj
-> src/App-ReactHooksTemplate.cmj
Finish compiling(exit: 1)
Where am I going wrong?
DISCLAIMER: I don't know ReasonML, however
If it was OCaml, you'd just write IPV4, no need to qualify it like ipAddr.IPV4.
Perhaps this is the same in Reason?
I have solved this another way. Instead of passing the variant as prop, I simply rendered different components based on variant value.
[#react.component]
let make = () => {
let appData = Data.tileData;
switch (selected) {
| IPV4 =>
<div>
<IPV4Renderer appData />
</div>
| IPV6 =>
<div>
<IPV6Renderer appData />
</div>
};
};

Any way to set PrimaryHeader from codebehind in ShieldUi BarChart

I am using the asp.net version of shieldui for charts and have a barchart and would like to set the primaryHeader or secondaryHeader with data from the database. I searched the documentation page of shieldui website and could not find anything.
What I tried is something like this:
<shield:ShieldChart ID="ShieldChart1" Width="100%" Height="200px" runat="server"
OnTakeDataSource="ShieldChart1_TakeDataSource"
CssClass="chart">
<PrimaryHeader Text=" ">
<Style Bold="true" FontSize="30px" />
</PrimaryHeader>
<SecondaryHeader Text="<asp:Label id="CardInvoiced" runat="server"/> ">
</SecondaryHeader>
<ExportOptions AllowExportToImage="false" AllowPrint="false" />
<Axes>
<shield:ChartAxisX
CategoricalValuesField="Area">
</shield:ChartAxisX>
<shield:ChartAxisY>
</shield:ChartAxisY>
</Axes>
<DataSeries>
<shield:ChartBarSeries DataFieldY="Sales" CollectionAlias="signups">
</shield:ChartBarSeries>
<shield:ChartBarSeries DataFieldY="Starts" CollectionAlias="starts">
</shield:ChartBarSeries>
<shield:ChartBarSeries DataFieldY="bis" CollectionAlias="bis">
</shield:ChartBarSeries>
<shield:ChartBarSeries DataFieldY="comps" CollectionAlias="comps">
</shield:ChartBarSeries>
</DataSeries>
</shield:ShieldChart>
ShieldUI error is:
Type 'Shield.Web.UI.ShieldChart' does not have a public property named 'Label'.
Any suggestion on how to accomplish this?
I solved this and here is how you set both PrimaryHeader and SecondaryHeader in ShieldUi graphs:
ShieldChartFSS7R.PrimaryHeader.Text = "Test Primary Header";
ShieldChartFSS7R.SecondaryHeader.Text = "Test Secondary Header";
Which shows the headers like this:

Selecting a field in Protractor

<hs-details-item>
<hs-label>Location</hs-label>
<hs-value-block>
<hs>
<hs-text-box ng-class="{'disabled': isAmenityPosting }" class="required" input-control="{title:'Location', okCallback:setJobSite, value:jobSiteName,
autocomplete:{ values:getJobSiteList, reload: true }, ss:'location'}">
<i class="icon-room"></i><span hs-placeholder="Select Location" class="ng-binding"></span>
</hs-text-box>
</hs>
<hs>
<!-- ngIf: isBarcodeShow() --><hs-button ng-class="{'disabled': soCreating }" class="barcode-special-btn smaller ng-scope" ng-if="isBarcodeShow()" hs-gesture="{handler:startScan, param: onBarcodeScanCompleted}"><i class="icon-br-code"></i></hs-button><!-- end ngIf: isBarcodeShow() -->
</hs>
</hs-value-block>
</hs-details-item>
Scenario: click on “Location” field...
What would be the best way to come up with a command in Protractor to select "location" field from the above Snippet Code?
Can it be done by not using Xpath?
Multiple options here. A sort of a non-welcomed, but short and readable way, would be to use an XPath expression and check the preceding label:
var locationTextBox = element(by.xpath("//hs-label[. = 'Location']/following::hs-text-box"));
locationTextBox.click();

Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement 5

I am newbie in coding. i just create new members data for my travel agent, i am confusing when this code is not running well. when the first time i use this code for 4 rows in mysqli its running well, but when i tried for complex data, its not running.
here is mysqli code:
if(isset($_GET['id'])):
if(isset($_POST['submit'])):
$stmt = $mysqli->prepare("UPDATE jamaah SET berangkatbulan=?, berangkattahun=?,bulandaftar=?, tahundaftar=?, nomorktp=?, namapertama=?,
namakedua=?, namaketiga=?, namaayahkandung=?, tempattanggallahir=?,
umur=?, jeniskelamin=?, kewarganegaraan=?, alamatlengkap=?, rtrw=?, kelurahan=?, kecamatan=?,
kabupaten=?, provinsi=?, kodepos=?, nomortelepon=?,
nomerhp=?, email=?, alamatjakarta=?, pendidikan=?, pekerjaan=?, pernahhaji=?, namamahram=?, hubunganmahram=?,
golongandarah=?, pilihpaket=? WHERE id=?");
$stmt->bind_param('sssssssssssssssssssssssssssssss', $berangkatbulan, $berangkattahun, $bulandaftar, $tahundaftar, $nomorktp, $namapertama,$namakedua, $namaketiga, $namaayahkandung,
$tempattanggallahir, $umur, $jeniskelamin, $kewarganegaraan, $alamatlengkap, $rtrw, $kelurahan, $kecamatan, $kabupaten,$provinsi,$kodepos,
$nomortelepon,$nomerhp,$email, $alamatjakarta,$pendidikan, $pekerjaan, $pernahhaji, $namamahram,$hubunganmahram, $golongandarah, $pilihpaket);
$berangkatbulan=$_POST['berangkatbulan'];
$berangkattahun=$_POST['berangkattahun'];
$bulandaftar=$_POST['bulandaftar'];
$tahundaftar=$_POST['tahundaftar'];
$nomorktp=$_POST['nomorktp'];
$namapertama=$_POST['namapertama'];
$namakedua=$_POST['namakedua'];
$namaketiga=$_POST['namaketiga'];
$namaayahkandung=$_POST['namaayahkandung'];
$tempattanggallahir=$_POST['tempattanggallahir'];
$umur=$_POST['umur'];
$jeniskelamin=$_POST['jeniskelamin'];
$kewarganegaraan=$_POST['kewarganegaraan'];
$alamatlengkap=$_POST['alamatlengkap'];
$rtrw=$_POST['rtrw'];
$kelurahan=$_POST['kelurahan'];
$kecamatan=$_POST['kecamatan'];
$kabupaten=$_POST['kabupaten'];
$provinsi=$_POST['provinsi'];
$kodepos=$_POST['kodepos'];
$nomortelepon = $_POST['nomortelepon'];
$nomerhp=$_POST['nomerhp'];
$email=$_POST['email'];
$alamatjakarta=$_POST['alamatjakarta'];
$pendidikan=$_POST['pendidikan'];
$pekerjaan=$_POST['pekerjaan'];
$pernahhaji=$_POST['pernahhaji'];
$namamahram=$_POST['namamahram'];
$hubunganmahram=$_POST['hubunganmahram'];
$golongandarah=$_POST['golongandarah'];
$pilihpaket=$_POST['pilihpaket'];
$id = $_POST['id'];
if($stmt->execute()):
echo "<script>location.href='index.php'</script>";
else:
echo "<script>alert('".$stmt->error."')</script>";
endif;
endif;
$res = $mysqli->query("SELECT * FROM jamaah WHERE id=".$_GET['id']);
$row = $res->fetch_assoc();
when i click an update mysqli message is :
**Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in D:\xampp\htdocs\datarematour\admin\update.php on line 11**
and this is my sample php codes:
<label for="kewarganegaraan">Kewarganegaraan</label>
<select name="kewarganegaraan" class="form-control">
<option>-Pilih--</option>
<option value="<?php echo $row['kewarganegaraan'] ?>">Warga Negara Indonesia</option>
<option>Warga Negara Asing</option>
</select>
<div class="col-xs-6 col-md-4 form-group">
<label for="namapertama">Nama Pertama</label>
<input type="text" name="namapertama" value="<?php echo $row['namapertama'] ?>" class="form-control">
</div>
The error message says it all:
Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement
Your query itself contains 32 question marks where your bind parameter fills the first 31 parameters but not the last one, the id
you have to add an i to the string variable of bind_param and then the variable containing the id value behind all the other variables

Capybara choose method Unable to find radio button

I have a form which is generated by simple form:
TL TR
<div class="form-group radio_buttons required user_register_temp_package">
<label class="radio_buttons required control-label">
<abbr title="zorunlu">
*
</abbr>
Paket
</label>
<label class="radio">
<input class="radio_buttons required" id="user_register_temp_attributes_domain_package_id_1" name="user[register_temp_attributes][domain_package_id]" type="radio" value="1">
Small
</label>
<label class="radio">
<input checked="checked" class="radio_buttons required" id="user_register_temp_attributes_domain_package_id_2" name="user[register_temp_attributes][domain_package_id]" type="radio" value="2">
Medium
</label>
<label class="radio">
<input class="radio_buttons required" id="user_register_temp_attributes_domain_package_id_3" name="user[register_temp_attributes][domain_package_id]" type="radio" value="3">
Large
</label>
</div>
TL TR
I have a simple spec like this:
# encoding: UTF-8
require 'spec_helper'
feature 'Register' do
background do
visit new_user_registration_path
end
scenario 'fill register form and register' do
# TL TR
choose('user_register_temp_attributes_domain_package_id_1')
# TL TR
end
end
My spec_helper.rb is
ENV['RAILS_ENV'] ||= 'test'
require File
.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
Capybara.javascript_driver = :webkit
Capybara.default_selector = :css
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
# Capybara DSL
config.include Capybara::DSL
# Factory girl
config.include FactoryGirl::Syntax::Methods
end
The Capybara API for the choose method says:
"Find a radio button and mark it as checked. The radio button can be found via name, id or label text."
But when I run spec with choose('user_register_temp_attributes_domain_package_id_1'), I get
Capybara::ElementNotFound: Unable to find radio button "user_register_temp_attributes_domain_package_id_1"
I've tried code below but got Capybara::ElementNotFound: Unable to find css "user_register_temp_attributes_domain_package_id_1" error:
find('#user_register_temp_attributes_domain_package_id_1[value=1]').set(true)
It seems there is no problem with fill_in, check or click_button methods.
Regards.
Most likely underlying driver thinks that this radio button is invisible. By default Capybara finds only visible elements (as Capybara.ignore_hidden_elements is true by default) so it didn't find that element.
Try:
choose('user_register_temp_attributes_domain_package_id_1', visible: false)
You can improve error message by submitting a pull request to Capybara.