How to scroll All Search Hashtag result in instagram With SELENIUM - selenium-webdriver

I want to get all the users using #book from the Instagram site, but I can only get one page of results,
If there are about 2000 pages.
This code does not work properly :
EOS = wd.execute_script('return document.body.scrollHeight')
while True:
wd.execute_script('window.scrollTo(0,document.body.scrollHeight);')
sleep(7)
my_scroll = wd.execute_script('return document.body.scrollHeight')
print (my_scroll)
if my_scroll == EOS:
break
EOS = my_scroll

Related

How to retrieve URL from a browser with UIautomation and plain C

I want to obtain the URL of the browser Internet Explorer. I found the following code (Get active Tab URL in Chrome with C++) in C++ and I am trying to convert it to plain C.
IUIAutomationCondition *pCondition = NULL;
VARIANT url;
VARIANT varProp;
varProp.vt = VT_I4;
varProp.lVal = UIA_EditControlTypeId;
hr = IUIAutomation_CreatePropertyCondition(pAutomation,UIA_ControlTypePropertyId,varProp,&pCondition);
if(SUCCEEDED(hr)){
hr = IUIAutomationElement_FindFirst(pNode,TreeScope_Descendants,pCondition,&urlBar);
if(urlBar!= NULL){
IUIAutomationElement_GetCurrentPropertyValue(urlBar,UIA_ValueValuePropertyId,&url);
MessageBox(0, url.bstrVal, L"success", 0);
}
}
IUnknown_Release(pCondition);
This code prints the text URL "h" in the message box when I want to retrieve the value from the browser and the value should be www.amazon.com. I do not know what I am doing incorrectly. I really appreciate if someone could help me out.
The variable url.bstrVal is BSTR, then I should use MessageBoxW. With MessageBox, the code was printing only the first letter of the url. With MessageBoxW, I could print the whole URL.

RichText rendering issue for anonymous users

I am trying to render richtext content from WCM using wcm API. I have jsp to do so. It renders properly for all user group except anonymous. When I view rendered content I see broken image inside richtext. When I log in and view the rendered content, image is displayed.
here is my code:
Workspace ws = WCM_API.getRepository().getSystemWorkspace();
ws.login();
DocumentLibrary lib = ws.getDocumentLibrary("Portal Site");
String s1 = "";
String s2 = "";
if (lib!=null) {
DocumentIdIterator<Document> it = ws.findByName(DocumentTypes.Content,"kino");
if (it.hasNext()) {
DocumentId<Document> docid = it.next();
Content doc = (Content) ws.getById(docid);
s1 = "Title: " + doc.getTitle() + "\n";
RichTextComponent c = (RichTextComponent) doc.getComponent("Body");
s2 = "Text: " + c.getRichText();
}
}
out.println(s1);
out.println(s2);
s2 is outputs richtext with image for authorized users.
When I logout and view s2 output: text is displayed but image is broken
Please make sure that you have anonymous access granted to all your RichText component and parent site areas at user level.
And add this call on workspace object
workspace.useUserAccess(true);
Solution has nothing to do with access level in my case!
I checked url of the content and in both cases it consisted /myconnect word (example: http:ip_address:port/wps/wcm/myconnect/...)
I found out that myconnect is for authorized user
and connect is for anon users. (example: http:ip_address:port/wps/wcm/connect/...)
Just by replacing myconnect with connect in the url to the wcm content I managed to solve the problem:

Protractor-net, non angular login page

Using protractor-net, Login page is non-angular, where as the home page is angular. hence cannot launch browser with url using NgWebDriver, probably since its looking for angular. tried angular.ignoreSynchronization="false". But same issue. If I use angDriver.WrappedDriver.FindElement to cross login, the angular objects in home page are not recognized-Asynchronous script error-timeout.
driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
angDriver = new NgWebDriver(driver,"[ng-app='Phoenix']");
string root=angDriver.RootElement;
angDriver.WrappedDriver.Navigate().GoToUrl(url);
angDriver.WrappedDriver.Manage().Window.Maximize();
driver = angDriver.WrappedDriver;
driver.FindElement(By.Id("UserID")).Clear();
driver.FindElement(By.Id("UserID")).SendKeys("");
driver.FindElement(By.Id("Password")).SendKeys("");
driver.FindElement(By.Id("searchsubmit")).Click();
System.Threading.Thread.Sleep(10000);
string dolAmt = angDriver.FindElement(NgBy.Binding("activeValue")).Text;
I am hoping this will do it.
_driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
_driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));;
//Do whatever for log in with chrome driver
string url = "url for angular page";
_ngWebDriver = new NgWebDriver(_driver, "[ng-app='Phoenix']");
//You have to naviagate to url in order the _ngWebDriver to know the angular page NOT click and go to angular page
_ngWebDriver.Navigate().GoToUrl(url);
_ngWebDriver.Manage().Window.Maximize();
//The script timeout is almost essential since most of protractor mechanism are dependent of client side script.
//start finding elements with NgBy class
NgWebElement ngElement = _ngWebDriver.FindElement(NgBy.Model("model"));
ngElement.Clear();
EDIT
driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
driver.FindElement(By.Id("UserID")).Clear();
driver.FindElement(By.Id("UserID")).SendKeys("");
driver.FindElement(By.Id("Password")).SendKeys("");
driver.FindElement(By.Id("searchsubmit")).Click();
// Phoenix is the ng-app of the coming angular page
string url = "url for angular page containing [ng-app='Phoenix']"
NgWebDriver angDriver = new NgWebDriver(driver,"[ng-app='Phoenix']");
// don't switch to wrapper driver
angDriver.Navigate().GoToUrl(url);
angDriver.Manage().Window.Maximize();
driver = angDriver.WrappedDriver;
string dolAmt = angDriver.FindElement(NgBy.Binding("activeValue")).Text;

Show Filtered Lookup in CRM2011 from Silverlight Grid

I recently show up all products on a "Lookup" Field on a Inline Silverlight App on the CRM2011 Quote form.
I do this with directly calling the link of the Lookup:
var uri = (ScriptObject)crmUri.Invoke("create", string.Format("/_controls/lookup/lookupinfo.aspx?LookupStyle=single&objecttypes={0}", objectType));
var dArgs = (ScriptObject)HtmlPage.Window.CreateInstance("Object");
dArgs.SetProperty("items", new string[] { "" });
dynamic dlgResult = HtmlPage.Window.Invoke("showModalDialog", uri, dArgs, "dialogWidth:500px;dialogHeight:700px");
Our Customer wants to filter the lookup view on a value of a specific field on the product form.
This field is a optionset and can be 1 or 2.
I tried to add "&$filter=" + "producttypecode/Value" + " eq 1" or "&$filter=" + "producttypecode" + " eq 1" in the link, but this always Returns a error message.
Are there any suggestions?
This is a valid request that I just tested.
ProductSet?$filter=ProductTypeCode/Value eq 1
If that doesn't work I'd recommend the following troubleshooting steps.
Test your full URL in a browser first.
If it works in a browser then fire up fiddler and see what the difference is between the silverlight request and your manual request using a browser.
If you are having difficulty determining the correct full url I'd recommend downloading and becoming familiar with the CRM OData Query Designer. It will allow you to use a GUI to generate your request strings, and test them out. It can be found here.
http://crm2011odatatool.codeplex.com/
We solved this issue by adding a new System View and call it from its URL.

Extjs4.1 - How to working with Progress bar and php

I try to create a Progress bar wait for server do something. When server finish then processbar will completed.
Here is my js
var pbar4 = Ext.create('Ext.ProgressBar', {
text:'Waiting on you...',
width: 300,
renderTo:Ext.getBody()
});
Ext.Ajax.request({
url: 'getStatus.php',
success: function(r) {
if (r.responseText == 100)
pbar4.updateText('All finished!');
else
pbar4.updateProgress(r.responseText, r.responseText+'% completed...');
}
});
and getStatus.php
$total = 10000;
for ($i = 0; $i <= $total; $i++) {
echo $i/$total*100;
}
But when i run that look like
How to do that thanks
What you have here is confusion about how ajax reacts with the page on the server. More specifically that pages aren't as stateful as you imagine them to be.
What you are assuming (or wanting) to happen:
Ajax request is made to PHP page from web page
PHP page receieves ajax request
PHP page starts loop
PHP page starts printing numbers
PHP page returns the current number it's on to the web page doing the ajax request
web page updates progress bar with first value
web page requests with ajax again
PHP prints out the current number it's on and returns that value to the requesting page
web page updates progress bar with current value
rinse and repeat steps 7 through 9
What is actually happening is quite simple:
Ajax request is made to PHP page from web page
PHP page receieves ajax request
PHP page starts loop
PHP prints all numbers in loop
PHP returns list of all numbers to web page
Web page prints list of all numbers as an update to the progress listener
To fix this issue you actually need to have the PHP page somehow be stateful as to the progress you want to represent here. This can be done by having PHP start a process (new thread, not sure if php has this) that writes numbers to a file on the first request and then have subsequence requests from the webpage read the last number in the file and have it return it. You could also use a database to do something similar.
In case somebody's looking now, I am also thinking of using a progressbar to monitor my Ajax. As previously mentioned, you cannot loop-print in PHP and read that. I did it like this:
Create a monitor ID in ExtJS.
Do the Ext.Ajax, passing the monitor ID
Create a Ext.util.TaskRunner();, monitoring a server file containing Jand updating progress bar
PHP side creates JSON file from monitor ID passed by ExtJS.
Update the JSON file in PHP by calling this several times:
Code:
$cnt = 0;
$total = 17; //number of times sendStatus(); was called
$monitorPath = '/path/to/file' . $_REQUEST['fileNameFromExtJS']
function sendStatus()
{
global $cnt, $total, $monitorPath;
$statusMessage = array(
"Tinkering stuff..",
"50% complete..",
"Sending...",
"Done!");
$statusMessage = $statusMessage[$cnt];
$cnt ++;
$str = '{"count": '.$cnt.', "total": '.$total.', statusMessage: "'.$statusMessage.'"}';
file_put_contents($monitorPath, $str, LOCK_EX );
}
Reference:
How to update Extjs Progress Bar with JSON results?
Progress bar in your web application, ExtJS / JAVA

Resources