问:
NullPointerException when adding ClickListener
I try to find a view by its ID but I get the NullPointerException. Have you any idea where am I doing wrong?

This is the exception I'm getting

```<code>E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.voicemail, PID: 24209
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.voicemail/com.example.voicemail.ComposeMail}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3162)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3305)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7285)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
        at com.example.voicemail.ComposeMail.onCreate(ComposeMail.java:34)
        at android.app.Activity.performCreate(Activity.java:7353)
        at android.app.Activity.performCreate(Activity.java:7344)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3142)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3305)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7285)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
</code>```

The code:

```<code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Initializing the views
    editTextEmail = (EditText) findViewById(R.id.editTextEmail);

    editTextSubject = (EditText) findViewById(R.id.editTextSubject);

    editTextMessage = (EditText) findViewById(R.id.editTextMessage);

    buttonSend = (Button) findViewById(R.id.buttonSend);

    buttonSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendEmail();
        }
    });
}

private void sendEmail() {
   //doSomething
}
</code>```

Here's my XML code

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bg2"
    android:padding="20dp"
    android:gravity="center_horizontal"
    tools:context=".ComposeMail">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="40dp"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:hint="@string/to"

        android:id="@+id/editTextEmail" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="40dp"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:hint="@string/subject"
        android:id="@+id/editTextSubject" />

    <EditText
        android:lines="15"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:hint="@string/message"
        android:gravity="top"
        android:id="@+id/editTextMessage" />

    <Button
        android:id="@+id/buttonSend"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_marginTop="20dp"
        android:background="@drawable/round_corner"
        android:text="@string/send"
        android:textColor="#ffffff"/>

</LinearLayout>
</code>```

I'm getting a NullPointerException on setOnClickListener. Basically I'm sending data from one activity to another using an intent. I have tried almost everything to solve this but it keeps on showing me the same exception. Please help me.

答: You are not calling an appropriate design layout. Please add setContentView(R.layout.ComposeMail); instead of     setContentView(R.layout.activity_main); in your class. Your class must call the appropriate design layout.

Body:
I try to find a view by its ID but I get the NullPointerException. Have you any idea where am I doing wrong?

This is the exception I'm getting

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.voicemail, PID: 24209
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.voicemail/com.example.voicemail.ComposeMail}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3162)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3305)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7285)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
        at com.example.voicemail.ComposeMail.onCreate(ComposeMail.java:34)
        at android.app.Activity.performCreate(Activity.java:7353)
        at android.app.Activity.performCreate(Activity.java:7344)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3142)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3305)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7285)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

The code:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Initializing the views
    editTextEmail = (EditText) findViewById(R.id.editTextEmail);

    editTextSubject = (EditText) findViewById(R.id.editTextSubject);

    editTextMessage = (EditText) findViewById(R.id.editTextMessage);

    buttonSend = (Button) findViewById(R.id.buttonSend);

    buttonSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendEmail();
        }
    });
}

private void sendEmail() {
   //doSomething
}

Here's my XML code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bg2"
    android:padding="20dp"
    android:gravity="center_horizontal"
    tools:context=".ComposeMail">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="40dp"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:hint="@string/to"

        android:id="@+id/editTextEmail" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="40dp"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:hint="@string/subject"
        android:id="@+id/editTextSubject" />

    <EditText
        android:lines="15"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:textColorHint="@android:color/white"
        android:textColor="@android:color/white"
        android:hint="@string/message"
        android:gravity="top"
        android:id="@+id/editTextMessage" />

    <Button
        android:id="@+id/buttonSend"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_marginTop="20dp"
        android:background="@drawable/round_corner"
        android:text="@string/send"
        android:textColor="#ffffff"/>

</LinearLayout>

I'm getting a NullPointerException on setOnClickListener. Basically I'm sending data from one activity to another using an intent. I have tried almost everything to solve this but it keeps on showing me the same exception. Please help me.


来源: stackexchange

问:
package org.apache.hadoop does not exist
I'm trying to compile a java file which is importing hadoop packages.

```<code>import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
</code>```

But it fails with a message

error: package org.apache.hadoop.fs does not exist

I googled for this error and it seems that I have to edit $PATH

But I have no idea to what I have to fix the path.

How can I solve this import error?

答:
You have bad import, its

```<code>import org.apache.hadoop.fs.Path;
</code>```

Not

```<code>import org.apahce.hadoop.fs.Path;
</code>```

The other posibility its you have bad import, can show how import the library of hadoop.

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to compile a java file which is importing hadoop packages.

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;

But it fails with a message

error: package org.apache.hadoop.fs does not exist

I googled for this error and it seems that I have to edit $PATH

But I have no idea to what I have to fix the path.

How can I solve this import error?

Body:
You have bad import, its

import org.apache.hadoop.fs.Path;

Not

import org.apahce.hadoop.fs.Path;

The other posibility its you have bad import, can show how import the library of hadoop.


问:
iphone : problem while fetching tweets from twitter
In my iphone app, I am trying to fetch tweets from twitter.

And I got one example coding from following link :

https://github.com/mattgemmell/MGTwitterEngine

But when i implemented this example I got following warning:

```<code>Ld build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo normal i386
 cd "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo"
  setenv MACOSX_DEPLOYMENT_TARGET 10.6
 setenv PATH      "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/Libraries & Headers/OAuthConsumer" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo" "-F/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" -filelist "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/XAuthTwitterEngineDemo.build/Debug-iphonesimulator/XAuthTwitterEngineDemo.build/Objects-normal/i386/XAuthTwitterEngineDemo.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -lOAuth -lsqlite3 -lxml2 -o "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo"

ld: in /Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/libxml2.dylib, file too small
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
</code>```

What can be done?

答:
The problem you are having lays with the fact that the MGTwitterEngine project is meant for Cocoa, so it links frameworks and libraries that are MacOS-only binaries. Specifically they are: libxml2 and AppKit.

In order to port this to iOS, you should create a new iOS project, import all the source code, and link to UIKit (this should already be ok) and to the iOS version of libxml2 (which you find when you do "add existing framework")....

ContentLicense: CC BY-SA 3.0

Body:
In my iphone app, I am trying to fetch tweets from twitter.

And I got one example coding from following link :

https://github.com/mattgemmell/MGTwitterEngine

But when i implemented this example I got following warning:

Ld build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo normal i386
 cd "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo"
  setenv MACOSX_DEPLOYMENT_TARGET 10.6
 setenv PATH      "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/Libraries & Headers/OAuthConsumer" "-L/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo" "-F/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator" -filelist "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/XAuthTwitterEngineDemo.build/Debug-iphonesimulator/XAuthTwitterEngineDemo.build/Objects-normal/i386/XAuthTwitterEngineDemo.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -lOAuth -lsqlite3 -lxml2 -o "/Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/build/Debug-iphonesimulator/XAuthTwitterEngineDemo.app/XAuthTwitterEngineDemo"

ld: in /Volumes/MacShare/ANKIT BACKUP/aral-XAuthTwitterEngine-8713a93/aral-XAuthTwitterEngine-8713a93/XAuthTwitterEngineDemo/libxml2.dylib, file too small
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

What can be done?


问:
am having issues launching my rails server using terminal. I have attached a screen shot of my issue! hope someone can help! Thanks
when i try to run rails server i get the following error! would be GREAT if someone could help!

Below is a screenshot of my code and error

答:
As your error log is saying 'Webpacker configuration file is not found', you need to run rails webpacker:install as given in error logs suggestion and try starting your server again.

Refer this answer


问:
Problem in Find Element after page changed in Selenium Python
im using a web scraper library as [Selenium] in python.
and i want to submit a form (multiple form without AJAX)

so , i wrote this code :

```<code>from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get('https://exportgram.com/')

one = driver.find_element_by_xpath('//*[@id="home"]/form/div[1]/div/input[1]')
one.click()
one.send_keys('https://www.instagram.com/p/B6OCVnTglgz/')
two = driver.find_element_by_xpath('//*[@id="home"]/form/div[2]/button')
two.click()
time.sleep(3)

three = driver.find_element_by_xpath('//*[@id="home"]/form/div[2]/button')
three.click()
</code>```

now , i cant access "three" because thats available on new page.

isnt any way to resolve that problem?

[Note : after click on 'two' , page changed to 'https://example.com/media.php']

答:
If after click on second element it redirect you to another page it means that this form is partially sent. You will be able to find a new DOM tree as soon as the browser loads the new address, so you have to wait for it to show up.

You can do this by this code:

```<code>from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

timeout = 10
three = WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.XPATH, '//*[@id="home"]/form/div[2]/button')), 'Time out')
three.click()
</code>```

Body:
im using a web scraper library as [Selenium] in python.
and i want to submit a form (multiple form without AJAX)

so , i wrote this code :

from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get('https://exportgram.com/')

one = driver.find_element_by_xpath('//*[@id="home"]/form/div[1]/div/input[1]')
one.click()
one.send_keys('https://www.instagram.com/p/B6OCVnTglgz/')
two = driver.find_element_by_xpath('//*[@id="home"]/form/div[2]/button')
two.click()
time.sleep(3)

three = driver.find_element_by_xpath('//*[@id="home"]/form/div[2]/button')
three.click()

now , i cant access "three" because thats available on new page.

isnt any way to resolve that problem?

[Note : after click on 'two' , page changed to 'https://example.com/media.php']

Body:
If after click on second element it redirect you to another page it means that this form is partially sent. You will be able to find a new DOM tree as soon as the browser loads the new address, so you have to wait for it to show up.

You can do this by this code:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

timeout = 10
three = WebDriverWait(driver, timeout).until(EC.presence_of_element_located((By.XPATH, '//*[@id="home"]/form/div[2]/button')), 'Time out')
three.click()


问:
Check within Jenkinsfile if docker service exists
I am setting up an CI Pipelin by means of Jenkins.

I created the following Jenkinsfile:

```<code>pipeline {
agent none

stages {
    stage('Build and push image') {
        agent {
                label 'man'
              }
        steps {
            sh 'docker image build -t login:stage .'
            sh 'docker tag login:stage 192.168.66.201:5000/login:stage'
            sh 'docker push 192.168.66.201:5000/login:stage'
        }
    }
    stage('Create Service') {
        agent {
                label 'dev'
              }
        steps {
            sh 'docker service create --name loginService -p 40001:40001 --replicas=3  192.168.66.201:5000/login:stage'
        }
    }
}
}
</code>```

I know, I could use the components of docker (docker.withRegistry) but I like to do it manually in first attempt to exactly knew what happens.

But my question is how to check in the "Create Service"-Stage, if a docker service already exists. If he exists I like to execute an update statement.

You've got any idea? Using google or jenkins docs did not really helped me..

答:
Another way to check if service already exists is to use inspect command and look at the exit code

```<code>def inspectExitCode = sh script: "docker service inspect loginService", returnStatus: true
if (inspectExitCode == 0) {
    sh "docker service update --name loginService ... "
} else {
    sh script: "docker service create --name loginService ... "
}
</code>```

In this case you won't run into the issue that was mentioned by @volker-schukai

Body:
I am setting up an CI Pipelin by means of Jenkins.

I created the following Jenkinsfile:

pipeline {
agent none

stages {
    stage('Build and push image') {
        agent {
                label 'man'
              }
        steps {
            sh 'docker image build -t login:stage .'
            sh 'docker tag login:stage 192.168.66.201:5000/login:stage'
            sh 'docker push 192.168.66.201:5000/login:stage'
        }
    }
    stage('Create Service') {
        agent {
                label 'dev'
              }
        steps {
            sh 'docker service create --name loginService -p 40001:40001 --replicas=3  192.168.66.201:5000/login:stage'
        }
    }
}
}

I know, I could use the components of docker (docker.withRegistry) but I like to do it manually in first attempt to exactly knew what happens.

But my question is how to check in the "Create Service"-Stage, if a docker service already exists. If he exists I like to execute an update statement.

You've got any idea? Using google or jenkins docs did not really helped me..

Body:
Another way to check if service already exists is to use inspect command and look at the exit code

def inspectExitCode = sh script: "docker service inspect loginService", returnStatus: true
if (inspectExitCode == 0) {
    sh "docker service update --name loginService ... "
} else {
    sh script: "docker service create --name loginService ... "
}

In this case you won't run into the issue that was mentioned by @volker-schukai


问:
Is there a keyboard shortcut for "Select all" in a terminal in Visual Studio Code?
Headline says it all:

Is there a keyboard shortcut for "Select all" in a terminal in Visual Studio Code?

I tried all the usual suspects (Ctrl-A, Ctrl-Shift-A) on Windows but none of them works.

答:
On windows vscode doesn't have "select all" shortcut by default.
Add this:

```<code>{ "key": "ctrl+a", "command": "workbench.action.terminal.selectAll",
                    "when": "terminalFocus" },
</code>```

to your keybindings.json file.
You can add keybindings by going to File->Preferences->Keyboard Shortcuts then press the "Open Keyboard Shortcuts (JSON)" button on the upper right of the text editor.

Body:
On windows vscode doesn't have "select all" shortcut by default.
Add this:

{ "key": "ctrl+a", "command": "workbench.action.terminal.selectAll",
                    "when": "terminalFocus" },

to your keybindings.json file.
You can add keybindings by going to File->Preferences->Keyboard Shortcuts then press the "Open Keyboard Shortcuts (JSON)" button on the upper right of the text editor.


问:
Regex to find items wrapped around with $()
I am looking for a regex that would search a string for occurrences of substring with the pattern $(...). So basically anything wrapped around with $(). So the string

```<code>string str = "Hello $(item)"
</code>```

would result true for that substring because it contains $(item)
My question is how do I regex check for wrapped up items with $(xx) in C#?

答:
You could use</p>

```<code>var found = Regex.Match(str,@"\$\([\s\S]+\)").Success;
</code>```

Body:
I am looking for a regex that would search a string for occurrences of substring with the pattern $(...). So basically anything wrapped around with $(). So the string

string str = "Hello $(item)"

would result true for that substring because it contains $(item)
My question is how do I regex check for wrapped up items with $(xx) in C#?

Body:
You could use

var found = Regex.Match(str,@"\$\([\s\S]+\)").Success;


问:
Responsive text field with icons and counter field
I am trying to create an input field where user can increment or decrement the number. The input field should look like following design in a responsive way

However, it looks weird when I did the following way

```<code><link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<div class="input-with-icon">
   <div class="labelled-input">
     <div class="labelling">
        <div class="content">
          <i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
          <div class="text-wrapper">
            <p class="adult">Adult</p>
            <p>16+year</p>
          </div>
       </div>
     </div>

     <div class="augment">
       <i class="fa fa-minus"></i>
     </div>
     <input type="text" class="input" disabled/>
     <div class="augment">
       <i class="fa fa-plus"></i>
     </div>

  </div>
</div>
</code>```

Here is the demo

https://jsbin.com/fiwabararo/edit?html,css,output

答:
Please check this code snippet

function counter(i){
  var el =document.getElementsByClassName('input');
(i == '+')
  ? el[0].value = parseInt(el[0].value) + 1
  :  el[0].value = parseInt(el[0].value) - 1;
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.input-with-icon {
  position: relative;
    width: 100%;
    display: flex;

}

.labelled-input {
   position: relative;
    font-weight: 400;
    font-style: normal;
    display: inline-flex;
    border: solid 1px #99acbd;
    border-radius: 2px;
    background:#eceef2;
}

.labelling {
  display: inline-block;
    line-height: 1;
    vertical-align: baseline;
    background-image: none;
    color: rgba(0, 0, 0, 0.6);
    text-transform: none;
    font-weight: 700;
    border: 0 solid transparent;
    flex: 0 0 auto;
    margin: 0;
}

.labelling:first-child {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
  }

.content {
  display: flex;
    align-items: center;
    padding:0 12px
}

.augment {
  background: #ccd5de;
  text-align:center;
    cursor: pointer;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    margin: 10px;
  margin-top:18px
}
.augment:hover {
  background: #478dcf;
}
.augment i {
  line-height:2.6;
  color:#fff
}

.input {
  margin: 0;
    border: none;
    outline: 0;
    box-shadow: none;
    font-size: 22px;
    font-weight: bold;
    text-align: center;
}
.input:disabled {
      background: #fff;
    }
@media(max-width:480px){
  .input {
    width:56%;
  }
  .augment {
      width: 14%;
   }
}</code>```

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

Adult

16+year

     <input type="text" class="input" disabled value="0"  />

```

Body:
I am trying to create an input field where user can increment or decrement the number. The input field should look like following design in a responsive way

However, it looks weird when I did the following way

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

Adult

16+year

     <input type="text" class="input" disabled/>

Here is the demo

https://jsbin.com/fiwabararo/edit?html,css,output

Body:
Please check this code snippet

function counter(i){
  var el =document.getElementsByClassName('input');
(i == '+')
  ? el[0].value = parseInt(el[0].value) + 1
  :  el[0].value = parseInt(el[0].value) - 1;
}

.input-with-icon {
  position: relative;
    width: 100%;
    display: flex;

}

.labelled-input {
   position: relative;
    font-weight: 400;
    font-style: normal;
    display: inline-flex;
    border: solid 1px #99acbd;
    border-radius: 2px;
    background:#eceef2;
}

.labelling {
  display: inline-block;
    line-height: 1;
    vertical-align: baseline;
    background-image: none;
    color: rgba(0, 0, 0, 0.6);
    text-transform: none;
    font-weight: 700;
    border: 0 solid transparent;
    flex: 0 0 auto;
    margin: 0;
}

.labelling:first-child {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
  }

.content {
  display: flex;
    align-items: center;
    padding:0 12px
}

.augment {
  background: #ccd5de;
  text-align:center;
    cursor: pointer;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    margin: 10px;
  margin-top:18px
}
.augment:hover {
  background: #478dcf;
}
.augment i {
  line-height:2.6;
  color:#fff
}

.input {
  margin: 0;
    border: none;
    outline: 0;
    box-shadow: none;
    font-size: 22px;
    font-weight: bold;
    text-align: center;
}
.input:disabled {
      background: #fff;
    }
@media(max-width:480px){
  .input {
    width:56%;
  }
  .augment {
      width: 14%;
   }
}

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<div class="input-with-icon">
   <div class="labelled-input">
     <div class="labelling">
        <div class="content">
          <i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
          <div class="text-wrapper">
            <p class="adult">Adult</p>
            <p>16+year</p>
          </div>
       </div>
     </div>

     <div class="augment" onclick="counter('-')">
       <i class="fa fa-minus"></i>
     </div>
     <input type="text" class="input" disabled value="0"  />
     <div class="augment" onclick="counter('+')">
       <i class="fa fa-plus"></i>
     </div>

  </div>
</div>


问:
How to fo transfer learning of a resnet50 model with with own dataset?
I am trying to build a face verification system using keras and resnet50 model with vggface weights. The way i am trying to achieve this is by the following steps:

given two image i first find out the face using mtcnn as embeddings

then i calculate the cosine distance between two vector embeddings. the distance starts from 0 to 1..... (Here to be noted
that the lower the distance the same two faces is)

Using the pre-trained model of resnet50 i get fairly good result. But since the model was trained mostly on european data and i want face verification on indian sub-contient i cannot rely on that. I want to train them on my own dataset. I have 10000 classes with each class containing 2 image. With image augmentation  i can create 10-15 image per class from those two image.

here is the sample code i am using for training

```<code>base_model = VGGFace(model='resnet50',include_top=False,input_shape=(224, 224, 3))
base_model.layers.pop()
base_model.summary()
for layer in base_model.layers:
    layer.trainable = False

y=base_model.input
x=base_model.output
x=GlobalAveragePooling2D()(x)
x=Dense(1024,activation='relu')(x) #we add dense layers so that the model can learn more complex functions and classify for better results.
x=Dense(1024,activation='relu')(x) #dense layer 2
x=Dense(512,activation='relu')(x) #dense layer 3
preds=Dense(8322,activation='softmax')(x) #final layer with softmax activation

model=Model(inputs=base_model.input,outputs=preds)

model.compile(optimizer='Adam',loss='categorical_crossentropy',metrics=['accuracy'])

model.summary()
train_datagen=ImageDataGenerator(preprocessing_function=preprocess_input) #included in our dependencies

train_generator=train_datagen.flow_from_directory('/Users/imac/Desktop/Fayed/Facematching/testenv/facenet/Dataset/train', # this is where you specify the path to the main data folder
                                                 target_size=(224,224),
                                                 color_mode='rgb',
                                                 batch_size=32,
                                                 class_mode='categorical',
                                                 shuffle=True)
step_size_train=train_generator.n/train_generator.batch_size

model.fit_generator(generator=train_generator,
                   steps_per_epoch=step_size_train,
                   epochs=10)
model.save('directory')
</code>```

As far as the code code is concern what i understand is that i disable the last layer then add 4 layer train them and store them in a diectory.

i then load the model using

```<code>model=load_model('directory of my saved model')
model.summary()
yhat = model.predict(samples)
</code>```

i predict the embedding of two image and then calculate cosine distance. But the problem is that the prediction gets worsen with my trained model. For two image of same person the pre-trained model gives distance of 0.3 whereas my trained model show distance of 1.0. Although during training loss function is decreasing with each epoch and accuracy is increasing but that doesn't reflect on my prediction output. I want to increase the prediction result of pre-trained model.

How can i achieve that with my own data?

N.B: I am relatively new in machine learning and don't know a lot about model layers

答:
What I would suggest is to go with triplet or siamese with these many number of classes. Use MTCNN to extract faces and then use facenet architecture to generate 512 dimensions embedding vectors, then visualize it using TSNE plot. Every face will be assigned a small embedding cluster. Go through this link for Keras to generate face embeddings: Link.

Then, try Triplets semi-hard and hard loss on your dataset to cluster them into 10000 classes. It might help. Go through this detailed blog on triplet loss: Triplets. Codes to go through some of the repositries: Code.

Body:
I am trying to build a face verification system using keras and resnet50 model with vggface weights. The way i am trying to achieve this is by the following steps:

given two image i first find out the face using mtcnn as embeddings

then i calculate the cosine distance between two vector embeddings. the distance starts from 0 to 1..... (Here to be noted
that the lower the distance the same two faces is)

Using the pre-trained model of resnet50 i get fairly good result. But since the model was trained mostly on european data and i want face verification on indian sub-contient i cannot rely on that. I want to train them on my own dataset. I have 10000 classes with each class containing 2 image. With image augmentation  i can create 10-15 image per class from those two image.

here is the sample code i am using for training

base_model = VGGFace(model='resnet50',include_top=False,input_shape=(224, 224, 3))
base_model.layers.pop()
base_model.summary()
for layer in base_model.layers:
    layer.trainable = False

y=base_model.input
x=base_model.output
x=GlobalAveragePooling2D()(x)
x=Dense(1024,activation='relu')(x) #we add dense layers so that the model can learn more complex functions and classify for better results.
x=Dense(1024,activation='relu')(x) #dense layer 2
x=Dense(512,activation='relu')(x) #dense layer 3
preds=Dense(8322,activation='softmax')(x) #final layer with softmax activation

model=Model(inputs=base_model.input,outputs=preds)

model.compile(optimizer='Adam',loss='categorical_crossentropy',metrics=['accuracy'])

model.summary()
train_datagen=ImageDataGenerator(preprocessing_function=preprocess_input) #included in our dependencies

train_generator=train_datagen.flow_from_directory('/Users/imac/Desktop/Fayed/Facematching/testenv/facenet/Dataset/train', # this is where you specify the path to the main data folder
                                                 target_size=(224,224),
                                                 color_mode='rgb',
                                                 batch_size=32,
                                                 class_mode='categorical',
                                                 shuffle=True)
step_size_train=train_generator.n/train_generator.batch_size

model.fit_generator(generator=train_generator,
                   steps_per_epoch=step_size_train,
                   epochs=10)
model.save('directory')

As far as the code code is concern what i understand is that i disable the last layer then add 4 layer train them and store them in a diectory.

i then load the model using

model=load_model('directory of my saved model')
model.summary()
yhat = model.predict(samples)

i predict the embedding of two image and then calculate cosine distance. But the problem is that the prediction gets worsen with my trained model. For two image of same person the pre-trained model gives distance of 0.3 whereas my trained model show distance of 1.0. Although during training loss function is decreasing with each epoch and accuracy is increasing but that doesn't reflect on my prediction output. I want to increase the prediction result of pre-trained model.

How can i achieve that with my own data?

N.B: I am relatively new in machine learning and don't know a lot about model layers


问:
How to avoid exception "Sharing violation on path /android/gms/R.java and /android/gms/base.R.java" in Xamarin.Android build?
When building a Xamarin Android project we sporadically get these exceptions. Any ideas how to remove the flakiness? Is this even solvable on our side or looks like an Xamarin Android bug?

```<code>/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000: Unhandled exception: System.IO.IOException: Sharing violation on path /Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/obj/Release/android/src/com/google/android/gms/R.java [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tools.Files.CopyIfStreamChanged (System.IO.Stream stream, System.String destination) [0x0002b] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfStreamChanged (System.IO.Stream source, System.String destination) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.GenerateLibraryResources.GenerateJava (Xamarin.Android.Tasks.GenerateLibraryResources+Library library) [0x0029c] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.AsyncTaskExtensions+<>c__DisplayClass0_0`1[TSource].<ParallelForEach>b__0 (TSource s) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000: Unhandled exception: System.IO.IOException: Sharing violation on path /Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/obj/Release/android/src/com/google/android/gms/base/R.java [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tools.Files.CopyIfStreamChanged (System.IO.Stream stream, System.String destination) [0x0002b] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfStreamChanged (System.IO.Stream source, System.String destination) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.GenerateLibraryResources.GenerateJava (Xamarin.Android.Tasks.GenerateLibraryResources+Library library) [0x0029c] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.AsyncTaskExtensions+<>c__DisplayClass0_0`1[TSource].<ParallelForEach>b__0 (TSource s) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
</code>```

We checked that the build agent has selected a valid $(TargetFrameworkVersion) and the required android api-level is installed in $(AndroidSdkDirectory)\platforms. We use Android 10 for the target framework version and SDK 29 is installed in /Users/Shared/Development/Android/sdk/platforms/android-29.

Visual Studio Version:

=== Visual Studio Community 2019 for Mac ===

Version 8.4 (build 2657) Installation UUID:
  59b142d8-4988-47b4-b8f6-69df598d76b6  GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 5.16.1.25 (issue-7441-d16-3-vsmac / 881172e73)

Package version: 606000155

=== Mono Framework MDK ===

Runtime:  Mono 6.6.0.155 (2019-08/296a9afdb24) (64-bit)   Package
  version: 606000155

=== Roslyn (Language Service) ===

3.4.0-beta4-19562-05+ff930dec4565e2bc424ad3bf3e22ecb20542c87d

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.100/Sdks SDK Versions:
    3.1.100
    2.1.802 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions:
    3.1.0
    2.1.14
    2.1.13

=== Xamarin.Profiler ===

Version: 1.6.12.29 Location: /Applications/Xamarin
  Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.3 (15712) Build 11C504

=== Xamarin.Mac ===

Version: 6.8.3.0 (Visual Studio Community) Hash: 0d8fe219c Branch:
  d16-4 Build date: 2019-12-04 13:06:40-0500

=== Xamarin.iOS ===

Version: 13.8.3.0 (Visual Studio Community) Hash: 0d8fe219c Branch:
  d16-4 Build date: 2019-12-04 13:06:41-0500

=== Xamarin Designer ===

Version: 16.4.0.468 Hash: 519082ea8 Branch: remotes/origin/d16-4 Build
  date: 2019-12-04 16:21:00 UTC

=== Xamarin.Android ===

Version: 10.1.1.0 (Visual Studio Community) Commit:
  xamarin-android/d16-4/f2c9364 Android SDK:
  /Users/Shared/Development/Android/sdk     Supported Android versions:
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.4 SDK Build
  Tools Version: 29.0.2

Build Information:  Mono: bef1e63 Java.Interop:
  xamarin/java.interop/d16-4@c4e569f ProGuard:
  xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4
  Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/Shared/Development/jdk/microsoft_dist_openjdk_8.0.25
  1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.4.0.9 Hash: 3f7256f Branch: remotes/origin/d16-4 Build
  date: 2019-12-19 18:59:12 UTC

=== Android Device Manager ===

Version: 16.4.0.28 Hash: 68e9956 Branch: remotes/origin/d16-4 Build
  date: 2019-12-19 18:59:32 UTC

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09
  Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 804002657 Git revision:
  4c6723413e884e024466fc93ff10e938bca7f721 Build date: 2020-01-06
  18:20:13+00 Build branch: release-8.4 Xamarin extensions:
  0f572cad12fd3886cd8e21a8b93b86e29ceaf111

=== Operating System ===

Mac OS X 10.15.2 Darwin 19.2.0 Darwin Kernel Version 19.2.0
      Sat Nov  9 03:47:04 PST 2019
      root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

答: After updating package Xamarin.Build.Download from version 0.7.1. to 0.8.0 we could not reproduce this error. We also updated packages that had this library as a dependency. In our case these were Xamarin.Firebase.Analytics and Xamarin.Android.Crashlytics.</p>

Body:
When building a Xamarin Android project we sporadically get these exceptions. Any ideas how to remove the flakiness? Is this even solvable on our side or looks like an Xamarin Android bug?

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000: Unhandled exception: System.IO.IOException: Sharing violation on path /Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/obj/Release/android/src/com/google/android/gms/R.java [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tools.Files.CopyIfStreamChanged (System.IO.Stream stream, System.String destination) [0x0002b] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfStreamChanged (System.IO.Stream source, System.String destination) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.GenerateLibraryResources.GenerateJava (Xamarin.Android.Tasks.GenerateLibraryResources+Library library) [0x0029c] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.AsyncTaskExtensions+<>c__DisplayClass0_0`1[TSource].<ParallelForEach>b__0 (TSource s) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000: Unhandled exception: System.IO.IOException: Sharing violation on path /Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/obj/Release/android/src/com/google/android/gms/base/R.java [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path, System.Int32 bufferSize) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at System.IO.File.Create (System.String path) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tools.Files.CopyIfStreamChanged (System.IO.Stream stream, System.String destination) [0x0002b] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.MonoAndroidHelper.CopyIfStreamChanged (System.IO.Stream source, System.String destination) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.GenerateLibraryResources.GenerateJava (Xamarin.Android.Tasks.GenerateLibraryResources+Library library) [0x0029c] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1669,2): error XA0000:   at Xamarin.Android.Tasks.AsyncTaskExtensions+<>c__DisplayClass0_0`1[TSource].<ParallelForEach>b__0 (TSource s) [0x00000] in <82010c32869043cdad86578a8131c7e9>:0  [/Users/APP/Development/BambooAgents/App-Agent-P-5/xml-data/build-dir/App-APP-APPDROID/src/App.Application.Droid/App.Application.Droid.csproj]

We checked that the build agent has selected a valid $(TargetFrameworkVersion) and the required android api-level is installed in $(AndroidSdkDirectory)\platforms. We use Android 10 for the target framework version and SDK 29 is installed in /Users/Shared/Development/Android/sdk/platforms/android-29.

Visual Studio Version:

=== Visual Studio Community 2019 for Mac ===

Version 8.4 (build 2657) Installation UUID:
  59b142d8-4988-47b4-b8f6-69df598d76b6  GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 5.16.1.25 (issue-7441-d16-3-vsmac / 881172e73)

Package version: 606000155

=== Mono Framework MDK ===

Runtime:  Mono 6.6.0.155 (2019-08/296a9afdb24) (64-bit)   Package
  version: 606000155

=== Roslyn (Language Service) ===

3.4.0-beta4-19562-05+ff930dec4565e2bc424ad3bf3e22ecb20542c87d

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.100/Sdks SDK Versions:
    3.1.100
    2.1.802 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions:
    3.1.0
    2.1.14
    2.1.13

=== Xamarin.Profiler ===

Version: 1.6.12.29 Location: /Applications/Xamarin
  Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.3 (15712) Build 11C504

=== Xamarin.Mac ===

Version: 6.8.3.0 (Visual Studio Community) Hash: 0d8fe219c Branch:
  d16-4 Build date: 2019-12-04 13:06:40-0500

=== Xamarin.iOS ===

Version: 13.8.3.0 (Visual Studio Community) Hash: 0d8fe219c Branch:
  d16-4 Build date: 2019-12-04 13:06:41-0500

=== Xamarin Designer ===

Version: 16.4.0.468 Hash: 519082ea8 Branch: remotes/origin/d16-4 Build
  date: 2019-12-04 16:21:00 UTC

=== Xamarin.Android ===

Version: 10.1.1.0 (Visual Studio Community) Commit:
  xamarin-android/d16-4/f2c9364 Android SDK:
  /Users/Shared/Development/Android/sdk     Supported Android versions:
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.4 SDK Build
  Tools Version: 29.0.2

Build Information:  Mono: bef1e63 Java.Interop:
  xamarin/java.interop/d16-4@c4e569f ProGuard:
  xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4
  Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/Shared/Development/jdk/microsoft_dist_openjdk_8.0.25
  1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.4.0.9 Hash: 3f7256f Branch: remotes/origin/d16-4 Build
  date: 2019-12-19 18:59:12 UTC

=== Android Device Manager ===

Version: 16.4.0.28 Hash: 68e9956 Branch: remotes/origin/d16-4 Build
  date: 2019-12-19 18:59:32 UTC

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09
  Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 804002657 Git revision:
  4c6723413e884e024466fc93ff10e938bca7f721 Build date: 2020-01-06
  18:20:13+00 Build branch: release-8.4 Xamarin extensions:
  0f572cad12fd3886cd8e21a8b93b86e29ceaf111

=== Operating System ===

Mac OS X 10.15.2 Darwin 19.2.0 Darwin Kernel Version 19.2.0
      Sat Nov  9 03:47:04 PST 2019
      root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64


问:
Request failed for https://docs.google.com returned code 400. Truncated server response:
So i try to make an script on https://script.google.com/ to automate data entry from google spreadsheet to google forms but i always receiving this code error

```<code>"Request failed for https://docs.google.com returned code 400. Truncated server response: <!DOCTYPE html><html lang="en" class="m2"><head><link rel="shortcut icon" sizes="16x16" href="https://ssl.gstatic.com/docs/spreadsheets/forms/favic... (use muteHttpExceptions option to examine full response) (line 25, file "Code")"
</code>```

Can somebody help me?

Here My code

```<code>function auto_data_entry() {

  var formURL="https://docs.google.com/forms/u/0/d/e/1FAIpQLSduXRTFWkeq1ZLRaiGzhmT58oUZSp20FHsT73_qMj8ZpobuqA/formResponse";

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht= wrkBk.getSheetByName("Sheet1");

  var Transaction1 = wrkSht.getRange("A1").getValue();
  var Transaction2 = wrkSht.getRange("A2").getValue();
  var Transaction3 = wrkSht.getRange("A3").getValue();
  var Transaction4 = wrkSht.getRange("A4").getValue();
  var Transaction5 = wrkSht.getRange("A5").getValue();

  var datamap={"entry.663378019":Transaction1,
   "entry.978525821":Transaction2,
   "entry.1636658367":Transaction3,
   "entry.1490939339":Transaction4,
   "entry.2066528728":Transaction5};

  var options = {
    "method": "post",
    "payload": datamap
  };

  UrlFetchApp.fetch(formURL, options);
}
</code>```

And here the sheet https://docs.google.com/spreadsheets/d/1-sLoKy6npftapr3QxoRIoYozBN6izei0E9uqF4yLg-8/edit?usp=sharing

And here was the form https://docs.google.com/forms/d/e/1FAIpQLSduXRTFWkeq1ZLRaiGzhmT58oUZSp20FHsT73_qMj8ZpobuqA/viewform

Thanks!

答:
Your main issue here is that you are trying to use the fetch method for a google form. Fetch works for making HTTP requests to websites so it will be overcomplicated to try to do this to a form as you would need to create a custom response on that side.

Automating data entries

An easier way of achieving what you want is to use the Form Response methods from Apps Script Google Form´s documentation for pre filling the form. This piece of code will automate data entries from google´s spreadsheet:

function auto_data_entry(){

  var url='YOUR FORM URL';

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht= wrkBk.getSheetByName("Sheet1")

  var Transaction1 = wrkSht.getRange("A1").getValue();
  var Transaction2 = wrkSht.getRange("A2").getValue();
  var Transaction3 = wrkSht.getRange("A3").getValue();
  var Transaction4 = wrkSht.getRange("A4").getValue();
  var Transaction5 = wrkSht.getRange("A5").getValue();

  var data = [Transaction1,Transaction2,Transaction3,Transaction4,Transaction5];

  var form = FormApp.openByUrl(url);
  var questions = form.getItems(); //get the different questions you want to pre fill
  var FormResponse = form.createResponse();
  //set a response from your response data array to the corresponding question until you fill the whole form
  for(i=0;i<5;i++){
    var qt = questions[i].asTextItem();
    var qr = qt.createResponse(data[i]);
    FormResponse.withItemResponse( qr );
  }
  //create a prefilled form
  var preurl = FormResponse.toPrefilledUrl();
  Logger.log(preurl);

}```
</div>
</div>
</p>

<blockquote>
  <p>NOTE: your pre filled form url is in the log.</p>
</blockquote>

<h2>Automating form submissions</h2>

<p>Also, if you wish to automate form submissions from your spreadsheet data you can use this code:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function auto_submission() {

  var url='YOUR FORM URL';

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht= wrkBk.getSheetByName("Sheet1")

  var Transaction1 = wrkSht.getRange("A1").getValue();
  var Transaction2 = wrkSht.getRange("A2").getValue();
  var Transaction3 = wrkSht.getRange("A3").getValue();
  var Transaction4 = wrkSht.getRange("A4").getValue();
  var Transaction5 = wrkSht.getRange("A5").getValue();

  var data = [Transaction1,Transaction2,Transaction3,Transaction4,Transaction5];

  var form = FormApp.openByUrl(url);
  var questions = form.getItems(); //get the different questions you want to fill
  var FormResponse = form.createResponse();
  //set a response from your response data array to the corresponding question until you fill the whole form
  for(i=0;i<5;i++){
    var qt = questions[i].asTextItem();
    var qr = qt.createResponse(data[i]);
    FormResponse.withItemResponse( qr );
  }
  //submit the form
  FormResponse.submit();

}</code>```

I hope this has helped you, let me know if you found any issues or if you do not understand anything.

Body:
So i try to make an script on https://script.google.com/ to automate data entry from google spreadsheet to google forms but i always receiving this code error

"Request failed for https://docs.google.com returned code 400. Truncated server response: <!DOCTYPE html><link rel="shortcut icon" sizes="16x16" href="https://ssl.gstatic.com/docs/spreadsheets/forms/favic... (use muteHttpExceptions option to examine full response) (line 25, file "Code")"

Can somebody help me?

Here My code

function auto_data_entry() {

  var formURL="https://docs.google.com/forms/u/0/d/e/1FAIpQLSduXRTFWkeq1ZLRaiGzhmT58oUZSp20FHsT73_qMj8ZpobuqA/formResponse";

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht= wrkBk.getSheetByName("Sheet1");

  var Transaction1 = wrkSht.getRange("A1").getValue();
  var Transaction2 = wrkSht.getRange("A2").getValue();
  var Transaction3 = wrkSht.getRange("A3").getValue();
  var Transaction4 = wrkSht.getRange("A4").getValue();
  var Transaction5 = wrkSht.getRange("A5").getValue();

  var datamap={"entry.663378019":Transaction1,
   "entry.978525821":Transaction2,
   "entry.1636658367":Transaction3,
   "entry.1490939339":Transaction4,
   "entry.2066528728":Transaction5};

  var options = {
    "method": "post",
    "payload": datamap
  };

  UrlFetchApp.fetch(formURL, options);
}

And here the sheet https://docs.google.com/spreadsheets/d/1-sLoKy6npftapr3QxoRIoYozBN6izei0E9uqF4yLg-8/edit?usp=sharing

And here was the form https://docs.google.com/forms/d/e/1FAIpQLSduXRTFWkeq1ZLRaiGzhmT58oUZSp20FHsT73_qMj8ZpobuqA/viewform

Thanks!

Body:
Your main issue here is that you are trying to use the fetch method for a google form. Fetch works for making HTTP requests to websites so it will be overcomplicated to try to do this to a form as you would need to create a custom response on that side.

Automating data entries

An easier way of achieving what you want is to use the Form Response methods from Apps Script Google Form´s documentation for pre filling the form. This piece of code will automate data entries from google´s spreadsheet:

function auto_data_entry(){

  var url='YOUR FORM URL';

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht= wrkBk.getSheetByName("Sheet1")

  var Transaction1 = wrkSht.getRange("A1").getValue();
  var Transaction2 = wrkSht.getRange("A2").getValue();
  var Transaction3 = wrkSht.getRange("A3").getValue();
  var Transaction4 = wrkSht.getRange("A4").getValue();
  var Transaction5 = wrkSht.getRange("A5").getValue();

  var data = [Transaction1,Transaction2,Transaction3,Transaction4,Transaction5];

  var form = FormApp.openByUrl(url);
  var questions = form.getItems(); //get the different questions you want to pre fill
  var FormResponse = form.createResponse();
  //set a response from your response data array to the corresponding question until you fill the whole form
  for(i=0;i<5;i++){
    var qt = questions[i].asTextItem();
    var qr = qt.createResponse(data[i]);
    FormResponse.withItemResponse( qr );
  }
  //create a prefilled form
  var preurl = FormResponse.toPrefilledUrl();
  Logger.log(preurl);

}

NOTE: your pre filled form url is in the log.

Automating form submissions

Also, if you wish to automate form submissions from your spreadsheet data you can use this code:

function auto_submission() {

  var url='YOUR FORM URL';

  var wrkBk = SpreadsheetApp.getActiveSpreadsheet();
  var wrkSht= wrkBk.getSheetByName("Sheet1")

  var Transaction1 = wrkSht.getRange("A1").getValue();
  var Transaction2 = wrkSht.getRange("A2").getValue();
  var Transaction3 = wrkSht.getRange("A3").getValue();
  var Transaction4 = wrkSht.getRange("A4").getValue();
  var Transaction5 = wrkSht.getRange("A5").getValue();

  var data = [Transaction1,Transaction2,Transaction3,Transaction4,Transaction5];

  var form = FormApp.openByUrl(url);
  var questions = form.getItems(); //get the different questions you want to fill
  var FormResponse = form.createResponse();
  //set a response from your response data array to the corresponding question until you fill the whole form
  for(i=0;i<5;i++){
    var qt = questions[i].asTextItem();
    var qr = qt.createResponse(data[i]);
    FormResponse.withItemResponse( qr );
  }
  //submit the form
  FormResponse.submit();

}

I hope this has helped you, let me know if you found any issues or if you do not understand anything.


问:
Breaking down array of objects into separate variables for database storage (React,express,sql server)
I have a stored array of objects within my reactjs application which when console logged looks like this.

```<code>0: {answer: "yes↵", question: "Is the keyboard separate from the screen?", state: "Declined with soloution defined"}
1: {answer: "yes", question: "Does the keyboard tilt?", state: "Accepted"}
2: {answer: "Question declined But not a problem", question: "Is it possible to find a comfortable typing postion?", state: "Accepted"}
3: {answer: "yes", question: "Do you have a good keyboard technique?", state: "Accepted"}
4: {answer: "Question declined But not a problem", question: "Are the characters on the keyboard clear and readable?", state: "Accepted"}
5: {answer: "sgdfgdfgdf", question: "Is your mouse or other pointing device suitable to the task you're using it for?", state: "problem specified"}
6: {answer: "yes", question: "Is the mouse (or other pointing device) located sufficently close to you?  ", state: "Accepted"}
7: {answer: "sdfsdfsdfsd", question: "Is there support for your wrist and forearm when using the mouse(or other pointing device)", state: "Declined with soloution defined"}
8: {answer: "yes", question: "Does the mouse (or other pointing device) work smoothly at a speed that suits you?", state: "Accepted"}
9: {answer: "asdasdas", question: "Can you easily adjust the software settings for speed and accuracy of the pointer?", state: "Declined with soloution defined"}
10: {answer: "asdasdads", question: "Are the characters on your screen clear and readable?", state: "problem specified"}
11: {answer: "yes", question: "Is the text size on your screen confortable to read?", state: "Accepted"}
12: {answer: "asdasdasd", question: "Is the image on your screen free from flicker and jitter?", state: "Declined with soloution defined"}
13: {answer: "asdasdasd", question: "Is your screen's specification suitable for its intended use?", state: "problem specified"}
14: {answer: "yes", question: "Is the brightness and/or contrast on your screen adjustable?", state: "Accepted"}
</code>```

this consists of answer, question and state (state of the answered question not state as in react components)

What I would like to do is pass these through to express so that I can upload them into my SQL database using the npm package mssql. However as these are all stored into the array I'm not sure how to split these up.

Ideally I would love to pass the whole object through to SQL and just store the whole thing in the database e.g (pseudo code)

```<code>insert into table where answer = answer and question = question and state = state
</code>```

Essentially to use this with SQL how would I break these down to be used with my back end or can I pass the whole object with a specific SQL stored procedure.

```<code>create procedure StoreAnswers

@{answer_values}
as

INSERT INTO QuestionResponses
(RUId, QuestionId, Date, QuestionWhenAnswered, QuestionResponse, Accepted, AssignedWorkStation )
VALUES
${answer_values}

</code>```

EDIT

Stored procedure

```<code>create procedure StoreAnswers(@Results varchar(max))
as begin
  insert into QuestionResponses(QuestionResponse, QuestionWhenAnswered, State)
         select substring(value, charindex('{answer: "', value) + 10,  charindex('", ', value, charindex('{answer: "', value) + 10) -  charindex('{answer: "', value) - 10) as answer,
                substring(value, charindex('question: "', value) + 11, charindex('", ', value, charindex('question: "', value) + 11) - charindex('question: "', value) - 11) as question,
                substring(value, charindex('state: "', value) + 8,      charindex('"}', value,  charindex('state: "', value) + 8) -     charindex('state: "', value) - 8) as state
         from string_split(@Results, char(10))
end;
</code>```

How it is passed through to the sql query from express npm

```<code>app.post("/post-question-answers", async (req, res) => {
  console.log("!called");

  let results = req.body.results;

  console.info(results);

  await sql.connect(config, function(err) {
    if (err) console.log(err);

    // create Request object
    var request = new sql.Request();
    request.input("Results", sql.VarChar, results);
    // query to the database and get the records
    request.execute("dbo.StoreAnswers", function(err, recordset) {
      if (err) console.log(err);
      // send records as a response
      res.json(recordset);
    });
  });

  res.statusCode = 400;
  res.statusMessage = "bad request";
  // res.json({ message: "Email Missing" });
});

</code>```

This is the console.info(results)

```<code>[
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the keyboard separate from the screen?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Does the keyboard tilt?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is it possible to find a comfortable typing postion?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Do you have a good keyboard technique?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Are the characters on the keyboard clear and readable?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: "Is your mouse or other pointing device suitable to the task you're using it for?",
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the mouse (or other pointing device) located sufficently close to you?  ',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is there support for your wrist and forearm when using the mouse(or other pointing device)',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Does the mouse (or other pointing device) work smoothly at a speed that suits you?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Can you easily adjust the software settings for speed and accuracy of the pointer?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Are the characters on your screen clear and readable?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the text size on your screen confortable to read?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the image on your screen free from flicker and jitter?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: "Is your screen's specification suitable for its intended use?",
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the brightness and/or contrast on your screen adjustable?',
[0]     state: 'Accepted'
[0]   }
[0] ]
</code>```

error

```<code>RequestError: Invalid length parameter passed to the LEFT or SUBSTRING function.
</code>```

答:
You can use string_split with the line feed character to separate your text into lines, and then use substring to separate your values within those lines, using charindex to identify their positions.

```<code>declare @text varchar(max) =
'0: {answer: "yes↵", question: "Is the keyboard separate from the screen?", state: "Declined with soloution defined"}
1: {answer: "yes", question: "Does the keyboard tilt?", state: "Accepted"}
2: {answer: "Question declined But not a problem", question: "Is it possible to find a comfortable typing postion?", state: "Accepted"}
3: {answer: "yes", question: "Do you have a good keyboard technique?", state: "Accepted"}
4: {answer: "Question declined But not a problem", question: "Are the characters on the keyboard clear and readable?", state: "Accepted"}
5: {answer: "sgdfgdfgdf", question: "Is your mouse or other pointing device suitable to the task you''re using it for?", state: "problem specified"}
6: {answer: "yes", question: "Is the mouse (or other pointing device) located sufficently close to you?  ", state: "Accepted"}
7: {answer: "sdfsdfsdfsd", question: "Is there support for your wrist and forearm when using the mouse(or other pointing device)", state: "Declined with soloution defined"}
8: {answer: "yes", question: "Does the mouse (or other pointing device) work smoothly at a speed that suits you?", state: "Accepted"}
9: {answer: "asdasdas", question: "Can you easily adjust the software settings for speed and accuracy of the pointer?", state: "Declined with soloution defined"}
10: {answer: "asdasdads", question: "Are the characters on your screen clear and readable?", state: "problem specified"}
11: {answer: "yes", question: "Is the text size on your screen confortable to read?", state: "Accepted"}
12: {answer: "asdasdasd", question: "Is the image on your screen free from flicker and jitter?", state: "Declined with soloution defined"}
13: {answer: "asdasdasd", question: "Is your screen''s specification suitable for its intended use?", state: "problem specified"}
14: {answer: "yes", question: "Is the brightness and/or contrast on your screen adjustable?", state: "Accepted"}'

select substring(value, charindex('{answer: "', value) + 10, charindex('", ', value, charindex('{answer: "', value) + 10) - charindex('{answer: "', value) - 10) as answer,
       substring(value, charindex('question: "', value) + 11, charindex('", ', value, charindex('question: "', value) + 11) - charindex('question: "', value) - 11) as question,
       substring(value, charindex('state: "', value) + 8, charindex('"}', value, charindex('state: "', value) + 8) - charindex('state: "', value) - 8) as state
from string_split(@text, char(10))
</code>```

You can see here that extraction working : http://sqlfiddle.com/#!18/9eecb/74353

So the stored procedure that accepts your text and inserts it into your table will be :

```<code>create procedure StoreAnswers(@text varchar(max))
as begin
  insert into QuestionResponses(answer, question, state)
         select substring(value, charindex('{answer: "', value) + 10,  charindex('", ', value, charindex('{answer: "', value) + 10) -  charindex('{answer: "', value) - 10) as answer,
                substring(value, charindex('question: "', value) + 11, charindex('", ', value, charindex('question: "', value) + 11) - charindex('question: "', value) - 11) as question,
                substring(value, charindex('state: "', value) + 8,      charindex('"}', value,  charindex('state: "', value) + 8) -     charindex('state: "', value) - 8) as state
         from string_split(@text, char(10))
end;
</code>```

Body:
I have a stored array of objects within my reactjs application which when console logged looks like this.

0: {answer: "yes↵", question: "Is the keyboard separate from the screen?", state: "Declined with soloution defined"}
1: {answer: "yes", question: "Does the keyboard tilt?", state: "Accepted"}
2: {answer: "Question declined But not a problem", question: "Is it possible to find a comfortable typing postion?", state: "Accepted"}
3: {answer: "yes", question: "Do you have a good keyboard technique?", state: "Accepted"}
4: {answer: "Question declined But not a problem", question: "Are the characters on the keyboard clear and readable?", state: "Accepted"}
5: {answer: "sgdfgdfgdf", question: "Is your mouse or other pointing device suitable to the task you're using it for?", state: "problem specified"}
6: {answer: "yes", question: "Is the mouse (or other pointing device) located sufficently close to you?  ", state: "Accepted"}
7: {answer: "sdfsdfsdfsd", question: "Is there support for your wrist and forearm when using the mouse(or other pointing device)", state: "Declined with soloution defined"}
8: {answer: "yes", question: "Does the mouse (or other pointing device) work smoothly at a speed that suits you?", state: "Accepted"}
9: {answer: "asdasdas", question: "Can you easily adjust the software settings for speed and accuracy of the pointer?", state: "Declined with soloution defined"}
10: {answer: "asdasdads", question: "Are the characters on your screen clear and readable?", state: "problem specified"}
11: {answer: "yes", question: "Is the text size on your screen confortable to read?", state: "Accepted"}
12: {answer: "asdasdasd", question: "Is the image on your screen free from flicker and jitter?", state: "Declined with soloution defined"}
13: {answer: "asdasdasd", question: "Is your screen's specification suitable for its intended use?", state: "problem specified"}
14: {answer: "yes", question: "Is the brightness and/or contrast on your screen adjustable?", state: "Accepted"}

this consists of answer, question and state (state of the answered question not state as in react components)

What I would like to do is pass these through to express so that I can upload them into my SQL database using the npm package mssql. However as these are all stored into the array I'm not sure how to split these up.

Ideally I would love to pass the whole object through to SQL and just store the whole thing in the database e.g (pseudo code)

insert into table where answer = answer and question = question and state = state

Essentially to use this with SQL how would I break these down to be used with my back end or can I pass the whole object with a specific SQL stored procedure.

create procedure StoreAnswers

@{answer_values}
as

INSERT INTO QuestionResponses
(RUId, QuestionId, Date, QuestionWhenAnswered, QuestionResponse, Accepted, AssignedWorkStation )
VALUES
${answer_values}

EDIT

Stored procedure

create procedure StoreAnswers(@Results varchar(max))
as begin
  insert into QuestionResponses(QuestionResponse, QuestionWhenAnswered, State)
         select substring(value, charindex('{answer: "', value) + 10,  charindex('", ', value, charindex('{answer: "', value) + 10) -  charindex('{answer: "', value) - 10) as answer,
                substring(value, charindex('question: "', value) + 11, charindex('", ', value, charindex('question: "', value) + 11) - charindex('question: "', value) - 11) as question,
                substring(value, charindex('state: "', value) + 8,      charindex('"}', value,  charindex('state: "', value) + 8) -     charindex('state: "', value) - 8) as state
         from string_split(@Results, char(10))
end;

How it is passed through to the sql query from express npm

app.post("/post-question-answers", async (req, res) => {
  console.log("!called");

  let results = req.body.results;

  console.info(results);

  await sql.connect(config, function(err) {
    if (err) console.log(err);

    // create Request object
    var request = new sql.Request();
    request.input("Results", sql.VarChar, results);
    // query to the database and get the records
    request.execute("dbo.StoreAnswers", function(err, recordset) {
      if (err) console.log(err);
      // send records as a response
      res.json(recordset);
    });
  });

  res.statusCode = 400;
  res.statusMessage = "bad request";
  // res.json({ message: "Email Missing" });
});

This is the console.info(results)

[
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the keyboard separate from the screen?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Does the keyboard tilt?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is it possible to find a comfortable typing postion?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Do you have a good keyboard technique?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Are the characters on the keyboard clear and readable?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: "Is your mouse or other pointing device suitable to the task you're using it for?",
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the mouse (or other pointing device) located sufficently close to you?  ',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is there support for your wrist and forearm when using the mouse(or other pointing device)',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Does the mouse (or other pointing device) work smoothly at a speed that suits you?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Can you easily adjust the software settings for speed and accuracy of the pointer?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Are the characters on your screen clear and readable?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the text size on your screen confortable to read?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the image on your screen free from flicker and jitter?',
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: "Is your screen's specification suitable for its intended use?",
[0]     state: 'Accepted'
[0]   },
[0]   {
[0]     answer: 'yes',
[0]     question: 'Is the brightness and/or contrast on your screen adjustable?',
[0]     state: 'Accepted'
[0]   }
[0] ]

error

RequestError: Invalid length parameter passed to the LEFT or SUBSTRING function.

Body:
You can use string_split with the line feed character to separate your text into lines, and then use substring to separate your values within those lines, using charindex to identify their positions.

declare @text varchar(max) =
'0: {answer: "yes↵", question: "Is the keyboard separate from the screen?", state: "Declined with soloution defined"}
1: {answer: "yes", question: "Does the keyboard tilt?", state: "Accepted"}
2: {answer: "Question declined But not a problem", question: "Is it possible to find a comfortable typing postion?", state: "Accepted"}
3: {answer: "yes", question: "Do you have a good keyboard technique?", state: "Accepted"}
4: {answer: "Question declined But not a problem", question: "Are the characters on the keyboard clear and readable?", state: "Accepted"}
5: {answer: "sgdfgdfgdf", question: "Is your mouse or other pointing device suitable to the task you''re using it for?", state: "problem specified"}
6: {answer: "yes", question: "Is the mouse (or other pointing device) located sufficently close to you?  ", state: "Accepted"}
7: {answer: "sdfsdfsdfsd", question: "Is there support for your wrist and forearm when using the mouse(or other pointing device)", state: "Declined with soloution defined"}
8: {answer: "yes", question: "Does the mouse (or other pointing device) work smoothly at a speed that suits you?", state: "Accepted"}
9: {answer: "asdasdas", question: "Can you easily adjust the software settings for speed and accuracy of the pointer?", state: "Declined with soloution defined"}
10: {answer: "asdasdads", question: "Are the characters on your screen clear and readable?", state: "problem specified"}
11: {answer: "yes", question: "Is the text size on your screen confortable to read?", state: "Accepted"}
12: {answer: "asdasdasd", question: "Is the image on your screen free from flicker and jitter?", state: "Declined with soloution defined"}
13: {answer: "asdasdasd", question: "Is your screen''s specification suitable for its intended use?", state: "problem specified"}
14: {answer: "yes", question: "Is the brightness and/or contrast on your screen adjustable?", state: "Accepted"}'

select substring(value, charindex('{answer: "', value) + 10, charindex('", ', value, charindex('{answer: "', value) + 10) - charindex('{answer: "', value) - 10) as answer,
       substring(value, charindex('question: "', value) + 11, charindex('", ', value, charindex('question: "', value) + 11) - charindex('question: "', value) - 11) as question,
       substring(value, charindex('state: "', value) + 8, charindex('"}', value, charindex('state: "', value) + 8) - charindex('state: "', value) - 8) as state
from string_split(@text, char(10))

You can see here that extraction working : http://sqlfiddle.com/#!18/9eecb/74353

So the stored procedure that accepts your text and inserts it into your table will be :

create procedure StoreAnswers(@text varchar(max))
as begin
  insert into QuestionResponses(answer, question, state)
         select substring(value, charindex('{answer: "', value) + 10,  charindex('", ', value, charindex('{answer: "', value) + 10) -  charindex('{answer: "', value) - 10) as answer,
                substring(value, charindex('question: "', value) + 11, charindex('", ', value, charindex('question: "', value) + 11) - charindex('question: "', value) - 11) as question,
                substring(value, charindex('state: "', value) + 8,      charindex('"}', value,  charindex('state: "', value) + 8) -     charindex('state: "', value) - 8) as state
         from string_split(@text, char(10))
end;


问:
Why am I getting an unexpected Error in Snowflake PUT load?
I am trying to load a local csv file to my staging area in Snowflake, and am using:

```<code>PUT file:'//Users/mark 1/Downloads/pp-complete.csv' @~ auto_compress=true;
</code>```

But I keep getting the error:

SQL compilation error: parse error line 1 at position 9 near '39'.
  syntax error line 1 at position 74 unexpected '

As far as I can tell, there's nothing 'wrong' with the SCV file. It opens fine in SublimeEdit and Excel, and I can't see anything 'funny' in there to account for this.

Am stuck now.

Thanks,
Mark

答:
```<code>PUT file://C:\\Users\\mark 1\\Downloads\\pp-complete.csv @~ auto_compress=true;
</code>```

Above command worked, added snip for your reference. Instead of single quotes use double slash to escape your path. So change your put command as like below and try.

Body:
I am trying to load a local csv file to my staging area in Snowflake, and am using:

PUT file:'//Users/mark 1/Downloads/pp-complete.csv' @~ auto_compress=true;

But I keep getting the error:

SQL compilation error: parse error line 1 at position 9 near '39'.
  syntax error line 1 at position 74 unexpected '

As far as I can tell, there's nothing 'wrong' with the SCV file. It opens fine in SublimeEdit and Excel, and I can't see anything 'funny' in there to account for this.

Am stuck now.

Thanks,
Mark

Body:
PUT file://C:\\Users\\mark 1\\Downloads\\pp-complete.csv @~ auto_compress=true;

Above command worked, added snip for your reference. Instead of single quotes use double slash to escape your path. So change your put command as like below and try.


问:
Passing WebElement as parameter to implicit wait method
I wrote the below method in my Page.class for reusing implicit wait.

```<code>public WebDriver waitForElementToLoad(WebElement element)
{
        WebDriverWait wait = new WebDriverWait(driver, 60);
        wait.until(ExpectedConditions.presenceOfElementLocated((By) element));
        return (driver);
}
</code>```

In my test.class I am using page factory elements, for example:

```<code>//Save button
@FindBy(xpath = "//*[@*='Save']")
private WebElement saveButton;
</code>```

Now I am trying to call:
waitForElementToLoad(saveButton);
from test.Class but I am getting below error.

"java.lang.ClassCastException: class com.sun.proxy.$Proxy12 cannot be
  cast to class org.openqa.selenium.By (com.sun.proxy.$Proxy12 and
  org.openqa.selenium.By are in unnamed module of loader 'app')"

I also tried

```<code>WebElement saveButton = driver.findElement(By.xpath("//*[@*='Save']"));
waitForElementToLoad(saveButton);
</code>```

but no luck.

How can I make this work?

答:
WebDriverWait is explicit wait, not implicit. And you can't cast WebElement to By.

If saveButton is not null than it was already found by the page factory, waiting for it presence is meaningless, that's why you don't have an overload with WebElement. Wait for  visibility instead

```<code>wait.until(ExpectedConditions.visibilityOf(element));
</code>```

Body:
I wrote the below method in my Page.class for reusing implicit wait.

public WebDriver waitForElementToLoad(WebElement element)
{
        WebDriverWait wait = new WebDriverWait(driver, 60);
        wait.until(ExpectedConditions.presenceOfElementLocated((By) element));
        return (driver);
}

In my test.class I am using page factory elements, for example:

//Save button
@FindBy(xpath = "//*[@*='Save']")
private WebElement saveButton;

Now I am trying to call:
waitForElementToLoad(saveButton);
from test.Class but I am getting below error.

"java.lang.ClassCastException: class com.sun.proxy.$Proxy12 cannot be
  cast to class org.openqa.selenium.By (com.sun.proxy.$Proxy12 and
  org.openqa.selenium.By are in unnamed module of loader 'app')"

I also tried

WebElement saveButton = driver.findElement(By.xpath("//*[@*='Save']"));
waitForElementToLoad(saveButton);

but no luck.

How can I make this work?

Body:
WebDriverWait is explicit wait, not implicit. And you can't cast WebElement to By.

If saveButton is not null than it was already found by the page factory, waiting for it presence is meaningless, that's why you don't have an overload with WebElement. Wait for  visibility instead

wait.until(ExpectedConditions.visibilityOf(element));


问:
Selenium IDE - execute a function foo.bar.getmyinfo()
I'm new to selenium IDE, but from the chrome devtools console, i can run a function like foo.bar.getmyinfo() . Can you execute this function and store the returned info in Selenium IDE? </p>

答:
Sure you can. See execute-script.</p>

```<code>execute-script | return foo.bar.getmyinfo(); | result
</code>```

Body:
Sure you can. See execute-script.

execute-script | return foo.bar.getmyinfo(); | result