I'm trying to include multiple blockquotes using markdown, but I'm stuck on the syntax for closing out the initial blockquote and starting a new one instead of continuing in the current blockquote and adding additional paragraphs...
=== Current syntax ===
> Review1
> -- <cite>Person1</cite>
> Review2
> -- <cite>Person2</cite>
=== Current result ===
<blockquote>
<p>Review1
-- <cite>Person1</cite></p>
<p>Review2
-- <cite>Person2</cite></p>
</blockquote>
=== Wanted result ===
<blockquote>
<p>Review1
-- <cite>Person1</cite></p>
</blockquote>
<blockquote>
<p>Review2
-- <cite>Person2</cite></p>
</blockquote>
Put in a comment
> Review1
> -- <cite>Person1</cite>
<!>
> Review2
> -- <cite>Person2</cite>
or a manual line break
> Review1
> -- <cite>Person1</cite>
<br>
> Review2
> -- <cite>Person2</cite>
Result
Review1
-- Person1
Review2
-- Person2
Related
I have Laravel code in Blade like this :
<span id="pk_dens" name="pk_dens" class="text-#if($productpages->pk_dens > 2.2 && $productpages->pk_dens < 3.3) success #else danger #endif">
{{$productpages->pk_dens}}%
</span>
So in class="text-#if($productpages->pk_dens > 2.2 && $productpages->pk_dens < 3.3) success #else danger #endif"
it will add space in class like text- danger and text- success so class not apply
so how can I avoid that spce in if else condition ?
Use ternary operator
<span id="pk_dens" name="pk_dens" class="text-{{ ($productpages->pk_dens > 2.2 && $productpages->pk_dens < 3.3) ? 'success' : 'danger' }}">
{{$productpages->pk_dens}}%
</span>
https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
I think you are missing here is ? in ternary syntax and to remove space just remove all white spaces from the span tag and make it in just one line.
<span id="pk_dens" name="pk_dens" class="text-{{ ($productpages->pk_dens > 2.2 && $productpages->pk_dens < 3.3) ? 'success' : 'danger' }}">{{$productpages->pk_dens}}%</span>
I have thins line of code
{{($user->company_privileges->level < 3 ? '' : ' disabled') }}
In my menu file
but when a user doesn't have a company I get the error
Trying to get property of non-object
Is their a neat way of dealing with this in one line?
Something like this comes to mind
{{ ($user->company_privileges === null) : '' ? ($user->company_privileges->level < 3 ? '' : ' disabled') ) }}
as the second if statement is only ran if the user has a company
I have the statement inside a tag aswell
<a class="{{($user->company_privileges->level < 3 ? '' : ' disabled') }}">
Why not something like
<a class="{{($user->company_privileges && $user->company_privileges->level < 3 ? '' : ' disabled') }}">
Essentially, what you need here is to know that null == false for bool comparison. Check out the PHP type comparisons table
I'm using FuncUnit with Jasmine to test my web application, and one issue I've run into consistently relates to typing into an input of type number.
<input type="number" min="0.01" step="0.01" pattern="[0-9]+([\.|,][0-9]+)?" class="form-control m-wrap m-ctrl-large" placeholder="10" onkeypress=" return isDecimalKey(event); ">
The isDecimalKey method basically checks typecodes to make sure that the user is entering a number or decimal point:
function isDecimalKey(e) {
var charCode = (e.which) ? e.which : event.keyCode;
if (charCode !== 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
else
return true;
}
When typing into the input manually, I'm able to highlight the current value with Ctrl+A, delete it with either backspace or the delete key, and enter a new value. However, when trying to do the same with FuncUnit, I get the following error:
Uncaught InvalidStateError: Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection.
I've tried the following methods of insertion:
F('input').visible().click().type('[ctrl]a[ctrl-up][delete] 6');
F('input').visible().click().type('[\b][\b] 6');
F('input').visible().click().type('6');
F('input').visible().dblclick().type('6');
So far, none of the above has worked. What is the best way for me to go about manipulating this input's value? Thanks!
I am a newbie to software test automation and have written the following test script in Selenium Webdriver and Ruby binding. It performs user actions (clicks, enters, fills up values etc.). I have put basic asserts that match the screen text value with value I provide. Below is the code:
puts "Test Run 1 has started ""["+Time.now.strftime('%H:%M:%S CST')+"]"
require "selenium-webdriver"
require "colorize"
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.cache.disk.enable'] = false
browser = $browser = Selenium::WebDriver.for :firefox, :profile => profile
browser.manage().window().maximize();
browser.get "https://cameleon-6945--dev.cs11.cloudforce.com"
main_window = browser.window_handle
browser.find_element(name:"username").clear()
browser.find_element(name:"username").send_keys "abcd#vertex.com"
browser.find_element(name:"pw").send_keys "1234"
browser.find_element(name:"Login").click
browser.find_element(link_text:"Cameleon Quotes").click
wait = Selenium::WebDriver::Wait.new(:timeout => 45)
#Open Test Run 1 created quote
wait.until {browser.find_element(:css,"#bodyCell > div.bRelatedList > div.hotListElement > div > div.pbBody > table > tbody > tr.dataRow.even.first > th > a")}
browser.find_element(:css,"#bodyCell > div.bRelatedList > div.hotListElement > div > div.pbBody > table > tbody > tr.dataRow.even.first > th > a").click
wait.until {browser.find_element(:xpath,"/html/body/div[3]/div[3]/div[2]/div[3]/div[2]/div[2]/div[2]/form/div[3]/div/div[2]/div[2]/div/div/div/table")}
#browser.save_screenshot "Cart Overview - RegressionRun # "+Time.now.strftime('%Y-%m-%d %H%M%S')+".jpeg"
#wait.until {browser.find_element(:css,"body > div.mainPartBox > div.boxBody > div.main > div.processBar > div.backgroundProcessBarMiddle > a:nth-child(7) > div.processBarElement.noSelected > div")}
#browser.find_element(:css,"body > div.mainPartBox > div.boxBody > div.main > div.processBar > div.backgroundProcessBarMiddle > a:nth-child(7) > div.processBarElement.noSelected > div").click
#wait.until {browser.find_element(:css,"body > div.CombinedBox > div.boxBody > div.main > div:nth-child(8) > iframe")}
#wait.until {browser.find_element(:xpath,"/html/body/div[3]/div[3]/div[2]/div[3]/iframe")}
browser.manage.timeouts.page_load = 35
#browser.switch_to.frame(cart_frame)
puts "\n\n"
puts "Assertions to verify cart content values\n\n".yellow
element_value1 = browser.find_element(:css,"#total > tbody > tr > td:nth-child(4) > span").text
if element_value1 == "$314,507.30"
puts 'Contract Sales Price = ' +element_value1
puts 'Value as expected in the cart, Test Passed'
else
puts 'Test failed, Contract Sales price value does not match the expected value'
end
puts "\n"
element_value2 = browser.find_element(:css,"#total > tbody > tr > td:nth-child(6) > span").text
if element_value2 == "$157,253.65"
puts 'Contract Cost Price = ' +element_value2
puts 'Value as expected in the cart, Test Passed'
else
puts 'Test failed, Contract Cost price value does not match the expected value'.red
end
puts "\n"
element_value3 = browser.find_element(:css,"#total > tbody > tr > td:nth-child(8) > span").text
if element_value3 == "50.00"
puts 'Contract gross margin = ' +element_value3
puts 'Value as expected in the cart, Test Passed'
else
puts 'Test failed, Gross margin value does not match the expected value'
end
puts "\n\n\t\t\t\t\tTest Case 1 passed successfully, proceeding to Test Case 2 - Generate Document\n".green
It's not integrated with any framework, it's just a test script.
My questions are:
Is this test totally worthless if compared to tools like Cucumber/Capybara etc.?
I have captured most of the elements using XPaths and this way the only way since it lacked classes, ids etc. Now if there's a minor change in page structure, like a new div is introduced, this script will fail with NoElemenFoundError. Is there any way we can avoid it? Or this is the only way test scripts are written and we need to update them regularly with new developments?
That exercise is worth doing once for your own experience. A couple of ways that using rspec for example would be an improvement are that rspec gives you a way to organize multiple tests, and that it boils down the results of your tests to a single indicator of success or failure, so that you can just look at the last line of output (or have your CI server look at the exit status) instead of reading pages of messages to see whether all your tests passed. Cucumber differs from rspec in that it allows you to read your entire test in English without reading any code in between, which is extremely valuable for thinking through requirements and might allow you to collaborate on your tests with non-programmers. Capybara provides methods that do much what you're doing in your script but are more succinct.
Sensitivity to page structure is an issue even with more sophisticated tools. One way to minimize the issue is to not assert any more of the page structure than you have to. If there is only one table on the page and only one row of results then td:nth-child(6) is all the selector you need. Another way to deal with that issue is to add IDs or classes to your pages to support testing.
I would say it is worth to have such scripts, but as soon as your number of scripts grows you need to manage them in a way where minimum maintenance is required.
So you can use various strategies to design a framework where you can have central object repository and test data. Refer here! for more details on designs.
I agree with Dave, to avoid assert on page structure. And if you maintain a central repository then there would be little modification needed if there is changes in structure of a page.
Is it possible for me to do something like this:
>ruby some_file.rb
>Your options are:
> 1. delete file blah.txt
> 2. delete file blah2.txt
> 3. delete file blah3.txt
> x to exit
> 1
> blah.txt was deleted
> 1. delete file blah.txt
> 2. delete file blah2.txt
> 3. delete file blah3.txt
> x to exit
> x
>
And this would read it's configuration from a file which would have all the files to delete.
I want this to be in a loop, so it keeps asking what to do unless you press 'x'.
How could you do this in Ruby?
You can read user input from standard input using Kernel#gets. This should hopefully point you in the right direction.
You need to create the configuration file your talking about that has all of the files you
need to delete.
Read the configuration file
Create a menu based on the configuration file
Read in user input and perform operations.
You can start from here:
def menu(choice)
case choice
when 1
# do_something
when 2
# ...
end
end
while ((a = gets) != "x\n")
menu(a)
end
as #Hunter McMillen stated you can use some configuration file to create the case-when programmatically.
if ARGV.size > 0
if FileTest.exists? ARGV[0]
files=[]
IO.readlines(ARGV[0]).each{|l| files.push(l.chop) if FileTest.exists? l.chop}
while files.size > 0
files.each_with_index{|f,i| puts "#{i+1}. #{f}"}
puts "x to exit"
opt = $stdin.gets.chop
break if opt == 'x'
opt = opt.to_i
puts "#{files.delete_at(opt-1)} was deleted" if opt > 0 && opt <= files.size && File.delete(files[opt-1]) > 0
end
end
end