AppleScript - accentued characters - safari

I have problem with special characters in AppleScript (service in Automator).
The selected text (title of a book) is the input (titre in the script), and the goal is to display in safari the result of the advanced research of this book on noosfere.org
It's ok when there is no accent characters in my selected text.
But if titre is sphère d'influence :
In the display box (only used for testing), "sphère d'influence" is correctly written with the "è".
But in safari, in the research field in the website, I have "sphère d''influence".
on run {titre, parameters}
set url_noosfere_titre to "https://www.noosfere.org/livres/noosearch.asp?Mots=" & titre & "&Envoyer=Envoyer&livres=livres&ModeRecherche=AND&ModeMoteur=MOTSCLEFS&recherche=1"
display dialog (url_noosfere_titre as text) buttons {"OK", "annulé"}
set retour to button returned of result
if retour is equal to "OK" then
open location url_noosfere_titre
end if
end run

URL with accents is very messy.
Basically URL's should be converted using 2 hexadecimal values with escape character '%'.For instance, "é", should be converted in %C3%A8.
However, result depends of web browser (IE, Safari, Chrome, Firefox) and versions. Sometime the browser is doing its own conversion which you can't avoid.
In your case, it is probably more efficient to change your mind and don't try to fill URL with the word you are searching for, but instead, just display the web page and set your word directly into the search area of the page, then click on the submit button ("Envoyer" in French).
In Applescript, you can manipulate a web page by using Javascript commands.
The script bellow displays your web page, add your word to search in the correct field, select the search area and submit the request by clicking on the submit button.
Doing that, no accent issue at all !
set BaseURL to "https://www.noosfere.org/livres/noosearch.asp?Mots"
set MyWord to "sphère"
tell application "Safari"
open location BaseURL
activate
delay 1 -- time to open the new window. Could be replaced by checking javascript load = complete
tell document 1
-- fill the search field of the page with expression to search
do JavaScript "document.getElementsByClassName('liste')[0].firstElementChild.children[1].value = '" & MyWord & "'"
-- check boxes for search area are 1, 3, 5,...17, 19 in "littérature" block
-- in this example, select the 2nd check box, so index is 3 (="Livres")
do JavaScript "document.getElementById('litt').children[3].click()"
-- click on the search button of the page (="Envoyer")
do JavaScript "document.getElementsByClassName('liste')[0].firstElementChild.children[2].click()"
end tell
end tell
fyi, I have been forced to add the selection of a search area (here I click on check box for all books ='Livres') because at least 1 selection in that area is mandatory.

Related

VBA macro how to click on button on website on chrome, using Selenium

I am trying to program to click on one button on website on chrome. The name of the button is "Add to Cart".
Please see HTML of the website:
enter image description here
And this is the VBA code:
CD.FindElementByCss("div.addToCartButtons clearAfter > button blue right s-addToCart > span.Add to Cart").Click
How can I do this?
Tags are important, you can anticipate some of the events attached to certain element in DOM just by reading its tag.
In your case you can click on the button tag directly instead of clicking the tag span, since this last one rarely has a .click event attached to it.
If you can provide an url to test this website I might help you better. This are the possible approaches:
1) Advanced:
a. Spaces in class are change for dots
b. Requires to understand tag's meaning and relative position of elements in DOM
'Example
'Clicking first button in div using only tag ("button" is a tag)
CD.FindElementByCss("div.addToCartButtons.clearAfter > button").Click
2) Intermedium:
a. Use only first Class and ignore all others after first space
b. Requires to understand what an elemment.child is
'Example:
'Clicking first child of "div" (Everything inside "div" is a child)
CD.FindElementByCss("div.addToCartButtons > button:nth-child(1)").Click
3) Easiest:
a. Double quotes ["] inside querySelector are changed to single quote [']
b. Requires to use Copy JS path in DevTools (Ctrl + Shif + I)
'Example:
'Clicking with Javascript in your website through ExecuteScript
strTemp = "document.querySelector('div.addToCartButtons clearAfter > button blue right s-addToCart').click"
CD.ExecuteScript (strTemp)

Find Message Number of Popup Dialog Text

I don't find the answer on the internet.
When I open some orders in a transaction, I have sometimes a popup. I want to execute some code if this popup text is 'Consider the subsequent documents'. If it is another text, I will execute some other code.
Problem is, we use SAP in several languages (EN, DE, FR), so I can't just say "if text = 'Consider the subsequent documents'. I know each message has its own ID in SAP. I know how to find this ID manually (see screenshot below), but I can't access it with findById(), even using the Record and Playback tool, because it uses the Performance Assistant window, which is not a children of the SAP session (it's a separate application, see second screenshot).
How could I do?
If session.ActiveWindow.Name = "wnd[1]" Then 'There is a popup
'Find message number (haven't find better way)
session.findById("wnd[1]/tbar[0]/btn[1]").press 'Press "Info"
'Line missing here to click the button in Performance Assistant Window. Record & Playback tool does not catch it.
If session.findById("wnd[2]/usr/txtHELP_INFO-MESSAGENR").Text = "081" Then
'Some code
End If
'close popups
session.findById("wnd[2]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
End If
I found out that it is possible to display the Help in a Modal window (=Popup) rather than in a separate window Performance Assistant. Then it is possible with findById() functions to get the message number Popup raises > F1 > F9 > findByID(...).Text
To set the Help in a Modal window, the user must first (manually or programmatically) check a setting:

Google search input text box can be found using name but not id

I am trying to go to the url "https://www.google.co.in" enter the word "Googling" in the input text box and then click on the search button.
The input text box has id "gs_htif0".
So the statement
driver.findElement(By.id("gs_htif0")).sendKeys("Googling");
should work. But it's not. The statement
driver.findElement(By.name("q")).sendKey("Googling");
is working fine. It fills the search box with the word "Googling".
It seems you tried incorrect id. Please check with :
driver.findElement(By.id("lst-ib")).sendKeys("Googling");

seleniumIDE - how to store a hyperlinks address and then visit that URL? Was working before

I had this working fine a couple of months ago but now when I run the test it fails and I don't know why or how to fix.
Background:
I have a screen with several links so that the 'admin' user who is currently logged in can login as one of the 'practitioners' via the login hyperlink presented.
Details:
So for my test I click on the 'Login link' hyperlink(s), enter & confirm a new password as required, and then I get to the practitioners screen 'as them'. The 'wrinkle' was that the pop-up for the user to enter their (new) password happened on a new window that the selenium IDE used was a new window. So basically just clicking on the hyperlink didn't work. To get around this I was able to store the hyperlink's href -a#href- in a selenium variable first_login_link_to and then use open instead of clickAndWait to visit the page, i.e. open ${first_login_link_to}
This was working fine a few months ago.... but it is not working now.
I get page doesn't exist and when I look at the url - urgh! It somehow includes the locator stuff and I am getting
http://dmplanning-stage.herokuapp.com//tr[td[contains(.,'6 Day')]][1]/td[8]/a#href
instead of
http://dmplanning-stage.herokuapp.com/p/zaH7m3aL7fxuPLvrc21L
in the browsers url address bar.
How can I get selenium to open the url stored in the variable and not use that 'locator' address?
selenium:
open /admin
clickAndWait link=practitioners
store //tr[td[contains(.,'6 Day')]][1]/td[8]/a#href
open ${first_login_link_to}
Found it - whew! Somehow my storeAttribute got changed to plain store.
Once I changed it back everything worked again!
This one worked for me
1-
Command = Store
Target = stuff you want to paste
Value = Var
2-
Command = sendkeys
Target = id for area where u wana paste
Value = ${Var}
3-
Command = Fireevent
Target = id for area where u wanna paste
Value = paste

SAS EG dynamic text field

is there a text field control in SAS EG ?
how can i set the selected prompt value ( parameter) into a text field(header is ok too) that will show in the report?
sorry , im new in SAS , so those term im using might not be the correct one.
It is possible to add prompted value to a header.
First go to the Prompt Manager under View menu
Click Add to create a new prompt
Give your prompt a name eg. HeaderText and a display text like Text to display in report header. In the second tab, make sure it's of the type text.
Open the properties (NOT modify, but bottom option of the right click) of the report you want your text to be displayed in.
Go to the prompts screen and add the prompt you just created and click OK.
Now open the modify window of the report.
Go to the titles screen, disable Default Text and enter &HeaderText. in the text field.
Run your flow. It will prompt for a text and that text will be printed in the header.